Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | From 649bd92cd2600719862ad5189899212409dd0a67 Mon Sep 17 00:00:00 2001 |
| 2 | From: Leon Merten Lohse <leon@green-side.de> |
| 3 | Date: Thu, 3 May 2012 23:50:30 +0100 |
| 4 | Subject: [PATCH] cdio: compensate for libcdio's recent cd-text api changes |
| 5 | |
| 6 | https://bugzilla.gnome.org/show_bug.cgi?id=675112 |
| 7 | |
| 8 | Conflicts: |
| 9 | |
| 10 | ext/cdio/gstcdiocddasrc.c |
| 11 | |
| 12 | Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com> |
| 13 | |
| 14 | Upstream-Status: Backport |
| 15 | --- |
| 16 | ext/cdio/gstcdio.c | 35 ++++++++++++++++++++++++++++------- |
| 17 | ext/cdio/gstcdio.h | 16 ++++++++++++++++ |
| 18 | ext/cdio/gstcdiocddasrc.c | 19 +++++++++++++++++++ |
| 19 | 3 files changed, 63 insertions(+), 7 deletions(-) |
| 20 | |
| 21 | diff --git a/ext/cdio/gstcdio.c b/ext/cdio/gstcdio.c |
| 22 | index 2f58d18..483ebf5 100644 |
| 23 | --- a/ext/cdio/gstcdio.c |
| 24 | +++ b/ext/cdio/gstcdio.c |
| 25 | @@ -30,12 +30,16 @@ |
| 26 | GST_DEBUG_CATEGORY (gst_cdio_debug); |
| 27 | |
| 28 | void |
| 29 | -gst_cdio_add_cdtext_field (GstObject * src, cdtext_t * cdtext, |
| 30 | +gst_cdio_add_cdtext_field (GstObject * src, cdtext_t * cdtext, track_t track, |
| 31 | cdtext_field_t field, const gchar * gst_tag, GstTagList ** p_tags) |
| 32 | { |
| 33 | const gchar *txt; |
| 34 | |
| 35 | +#if LIBCDIO_VERSION_NUM > 83 |
| 36 | + txt = cdtext_get_const (cdtext, field, track); |
| 37 | +#else |
| 38 | txt = cdtext_get_const (field, cdtext); |
| 39 | +#endif |
| 40 | if (txt == NULL || *txt == '\0') { |
| 41 | GST_DEBUG_OBJECT (src, "empty CD-TEXT field %u (%s)", field, gst_tag); |
| 42 | return; |
| 43 | @@ -57,6 +61,12 @@ gst_cdio_add_cdtext_field (GstObject * src, cdtext_t * cdtext, |
| 44 | } |
| 45 | |
| 46 | GstTagList * |
| 47 | +#if LIBCDIO_VERSION_NUM > 83 |
| 48 | +gst_cdio_get_cdtext (GstObject * src, cdtext_t * t, track_t track) |
| 49 | +{ |
| 50 | + GstTagList *tags = NULL; |
| 51 | + |
| 52 | +#else |
| 53 | gst_cdio_get_cdtext (GstObject * src, CdIo * cdio, track_t track) |
| 54 | { |
| 55 | GstTagList *tags = NULL; |
| 56 | @@ -67,14 +77,22 @@ gst_cdio_get_cdtext (GstObject * src, CdIo * cdio, track_t track) |
| 57 | GST_DEBUG_OBJECT (src, "no CD-TEXT for track %u", track); |
| 58 | return NULL; |
| 59 | } |
| 60 | +#endif |
| 61 | |
| 62 | - gst_cdio_add_cdtext_field (src, t, CDTEXT_PERFORMER, GST_TAG_ARTIST, &tags); |
| 63 | - gst_cdio_add_cdtext_field (src, t, CDTEXT_TITLE, GST_TAG_TITLE, &tags); |
| 64 | + gst_cdio_add_cdtext_field (src, t, track, CDTEXT_FIELD_PERFORMER, |
| 65 | + GST_TAG_ARTIST, &tags); |
| 66 | + gst_cdio_add_cdtext_field (src, t, track, CDTEXT_FIELD_TITLE, GST_TAG_TITLE, |
| 67 | + &tags); |
| 68 | |
| 69 | return tags; |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | +#if LIBCDIO_VERSION_NUM > 83 |
| 74 | +gst_cdio_add_cdtext_album_tags (GstObject * src, cdtext_t * t, |
| 75 | + GstTagList * tags) |
| 76 | +{ |
| 77 | +#else |
| 78 | gst_cdio_add_cdtext_album_tags (GstObject * src, CdIo * cdio, GstTagList * tags) |
| 79 | { |
| 80 | cdtext_t *t; |
| 81 | @@ -84,11 +102,14 @@ gst_cdio_add_cdtext_album_tags (GstObject * src, CdIo * cdio, GstTagList * tags) |
| 82 | GST_DEBUG_OBJECT (src, "no CD-TEXT for album"); |
| 83 | return; |
| 84 | } |
| 85 | +#endif |
| 86 | |
| 87 | - /* FIXME: map CDTEXT_PERFORMER to GST_TAG_ALBUM_ARTIST once we have that */ |
| 88 | - gst_cdio_add_cdtext_field (src, t, CDTEXT_TITLE, GST_TAG_ALBUM, &tags); |
| 89 | - gst_cdio_add_cdtext_field (src, t, CDTEXT_GENRE, GST_TAG_GENRE, &tags); |
| 90 | - |
| 91 | + gst_cdio_add_cdtext_field (src, t, 0, CDTEXT_FIELD_PERFORMER, |
| 92 | + GST_TAG_ALBUM_ARTIST, &tags); |
| 93 | + gst_cdio_add_cdtext_field (src, t, 0, CDTEXT_FIELD_TITLE, GST_TAG_ALBUM, |
| 94 | + &tags); |
| 95 | + gst_cdio_add_cdtext_field (src, t, 0, CDTEXT_FIELD_GENRE, GST_TAG_GENRE, |
| 96 | + &tags); |
| 97 | GST_DEBUG ("CD-TEXT album tags: %" GST_PTR_FORMAT, tags); |
| 98 | } |
| 99 | |
| 100 | diff --git a/ext/cdio/gstcdio.h b/ext/cdio/gstcdio.h |
| 101 | index ef31ed0..c6da580 100644 |
| 102 | --- a/ext/cdio/gstcdio.h |
| 103 | +++ b/ext/cdio/gstcdio.h |
| 104 | @@ -24,22 +24,38 @@ |
| 105 | #include <gst/gst.h> |
| 106 | #include <cdio/cdio.h> |
| 107 | #include <cdio/cdtext.h> |
| 108 | +#include <cdio/version.h> |
| 109 | + |
| 110 | +#if LIBCDIO_VERSION_NUM <= 83 |
| 111 | + #define CDTEXT_FIELD_PERFORMER CDTEXT_PERFORMER |
| 112 | + #define CDTEXT_FIELD_GENRE CDTEXT_GENRE |
| 113 | + #define CDTEXT_FIELD_TITLE CDTEXT_TITLE |
| 114 | +#endif |
| 115 | |
| 116 | GST_DEBUG_CATEGORY_EXTERN (gst_cdio_debug); |
| 117 | #define GST_CAT_DEFAULT gst_cdio_debug |
| 118 | |
| 119 | void gst_cdio_add_cdtext_field (GstObject * src, |
| 120 | cdtext_t * cdtext, |
| 121 | + track_t track, |
| 122 | cdtext_field_t field, |
| 123 | const gchar * gst_tag, |
| 124 | GstTagList ** p_tags); |
| 125 | |
| 126 | GstTagList * gst_cdio_get_cdtext (GstObject * src, |
| 127 | +#if LIBCDIO_VERSION_NUM > 83 |
| 128 | + cdtext_t * t, |
| 129 | +#else |
| 130 | CdIo * cdio, |
| 131 | +#endif |
| 132 | track_t track); |
| 133 | |
| 134 | void gst_cdio_add_cdtext_album_tags (GstObject * src, |
| 135 | +#if LIBCDIO_VERSION_NUM > 83 |
| 136 | + cdtext_t * t, |
| 137 | +#else |
| 138 | CdIo * cdio, |
| 139 | +#endif |
| 140 | GstTagList * tags); |
| 141 | |
| 142 | #endif /* __GST_CDIO_H__ */ |
| 143 | diff --git a/ext/cdio/gstcdiocddasrc.c b/ext/cdio/gstcdiocddasrc.c |
| 144 | index 615a0c8..830839e 100644 |
| 145 | --- a/ext/cdio/gstcdiocddasrc.c |
| 146 | +++ b/ext/cdio/gstcdiocddasrc.c |
| 147 | @@ -206,6 +206,9 @@ gst_cdio_cdda_src_open (GstAudioCdSrc * audiocdsrc, const gchar * device) |
| 148 | GstCdioCddaSrc *src; |
| 149 | discmode_t discmode; |
| 150 | gint first_track, num_tracks, i; |
| 151 | +#if LIBCDIO_VERSION_NUM > 83 |
| 152 | + cdtext_t *cdtext; |
| 153 | +#endif |
| 154 | |
| 155 | src = GST_CDIO_CDDA_SRC (audiocdsrc); |
| 156 | |
| 157 | @@ -244,8 +244,18 @@ gst_cdio_cdda_src_open (GstCddaBaseSrc * cddabasesrc, const gchar * device) |
| 158 | if (src->read_speed != -1) |
| 159 | cdio_set_speed (src->cdio, src->read_speed); |
| 160 | |
| 161 | +#if LIBCDIO_VERSION_NUM > 83 |
| 162 | + cdtext = cdio_get_cdtext (src->cdio); |
| 163 | + |
| 164 | + if (NULL == cdtext) |
| 165 | + GST_DEBUG_OBJECT (src, "no CD-TEXT on disc"); |
| 166 | + else |
| 167 | + gst_cdio_add_cdtext_album_tags (GST_OBJECT_CAST (src), cdtext, |
| 168 | + cddabasesrc->tags); |
| 169 | +#else |
| 170 | gst_cdio_add_cdtext_album_tags (GST_OBJECT_CAST (src), src->cdio, |
| 171 | cddabasesrc->tags); |
| 172 | +#endif |
| 173 | |
| 174 | GST_LOG_OBJECT (src, "%u tracks, first track: %d", num_tracks, first_track); |
| 175 | |
| 176 | @@ -250,8 +263,14 @@ gst_cdio_cdda_src_open (GstAudioCdSrc * audiocdsrc, const gchar * device) |
| 177 | * the right thing here (for cddb id calculations etc. as well) */ |
| 178 | track.start = cdio_get_track_lsn (src->cdio, i + first_track); |
| 179 | track.end = track.start + len_sectors - 1; /* -1? */ |
| 180 | +#if LIBCDIO_VERSION_NUM > 83 |
| 181 | + if (NULL != cdtext) |
| 182 | + track.tags = gst_cdio_get_cdtext (GST_OBJECT (src), cdtext, |
| 183 | + i + first_track); |
| 184 | +#else |
| 185 | track.tags = gst_cdio_get_cdtext (GST_OBJECT (src), src->cdio, |
| 186 | i + first_track); |
| 187 | +#endif |
| 188 | |
| 189 | gst_audio_cd_src_add_track (GST_AUDIO_CD_SRC (src), &track); |
| 190 | } |
| 191 | -- |
| 192 | 2.1.0 |
| 193 | |