audiocdsrc: make private bits private

This commit is contained in:
Tim-Philipp Müller 2011-12-30 16:12:30 +00:00
parent f562a29284
commit 31890ef59b
2 changed files with 246 additions and 209 deletions

View file

@ -116,6 +116,36 @@ enum
ARG_TOC_BIAS ARG_TOC_BIAS
}; };
#define GstIndex gpointer
struct _GstAudioCdSrcPrivate
{
GstAudioCdSrcMode mode;
gchar *device;
guint num_tracks;
guint num_all_tracks;
GstAudioCdSrcTrack *tracks;
gint cur_track; /* current track (starting from 0) */
gint prev_track; /* current track last time */
gint cur_sector; /* current sector */
gint seek_sector; /* -1 or sector to seek to */
gint uri_track;
gchar *uri;
guint32 discid; /* cddb disc id (for unit test) */
gchar mb_discid[32]; /* musicbrainz discid */
GstIndex *index;
gint index_id;
gint toc_offset;
gboolean toc_bias;
};
static void gst_audio_cd_src_uri_handler_init (gpointer g_iface, static void gst_audio_cd_src_uri_handler_init (gpointer g_iface,
gpointer iface_data); gpointer iface_data);
static void gst_audio_cd_src_get_property (GObject * object, guint prop_id, static void gst_audio_cd_src_get_property (GObject * object, guint prop_id,
@ -193,6 +223,8 @@ gst_audio_cd_src_class_init (GstAudioCdSrcClass * klass)
GST_DEBUG_CATEGORY_INIT (gst_audio_cd_src_debug, "audiocdsrc", 0, GST_DEBUG_CATEGORY_INIT (gst_audio_cd_src_debug, "audiocdsrc", 0,
"Audio CD source base class"); "Audio CD source base class");
g_type_class_add_private (klass, sizeof (GstAudioCdSrcPrivate));
/* our very own formats */ /* our very own formats */
track_format = gst_format_register ("track", "CD track"); track_format = gst_format_register ("track", "CD track");
sector_format = gst_format_register ("sector", "CD sector"); sector_format = gst_format_register ("sector", "CD sector");
@ -258,15 +290,19 @@ gst_audio_cd_src_class_init (GstAudioCdSrcClass * klass)
static void static void
gst_audio_cd_src_init (GstAudioCdSrc * src) gst_audio_cd_src_init (GstAudioCdSrc * src)
{ {
src->priv =
G_TYPE_INSTANCE_GET_PRIVATE (src, GST_TYPE_AUDIO_CD_SRC,
GstAudioCdSrcPrivate);
/* we're not live and we operate in time */ /* we're not live and we operate in time */
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
gst_base_src_set_live (GST_BASE_SRC (src), FALSE); gst_base_src_set_live (GST_BASE_SRC (src), FALSE);
GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_INDEXABLE); GST_OBJECT_FLAG_SET (src, GST_ELEMENT_FLAG_INDEXABLE);
src->device = NULL; src->priv->device = NULL;
src->mode = GST_AUDIO_CD_SRC_MODE_NORMAL; src->priv->mode = GST_AUDIO_CD_SRC_MODE_NORMAL;
src->uri_track = -1; src->priv->uri_track = -1;
} }
static void static void
@ -274,11 +310,11 @@ gst_audio_cd_src_finalize (GObject * obj)
{ {
GstAudioCdSrc *cddasrc = GST_AUDIO_CD_SRC (obj); GstAudioCdSrc *cddasrc = GST_AUDIO_CD_SRC (obj);
g_free (cddasrc->uri); g_free (cddasrc->priv->uri);
g_free (cddasrc->device); g_free (cddasrc->priv->device);
if (cddasrc->index) if (cddasrc->priv->index)
gst_object_unref (cddasrc->index); gst_object_unref (cddasrc->priv->index);
G_OBJECT_CLASS (parent_class)->finalize (obj); G_OBJECT_CLASS (parent_class)->finalize (obj);
} }
@ -286,9 +322,9 @@ gst_audio_cd_src_finalize (GObject * obj)
static void static void
gst_audio_cd_src_set_device (GstAudioCdSrc * src, const gchar * device) gst_audio_cd_src_set_device (GstAudioCdSrc * src, const gchar * device)
{ {
if (src->device) if (src->priv->device)
g_free (src->device); g_free (src->priv->device);
src->device = NULL; src->priv->device = NULL;
if (!device) if (!device)
return; return;
@ -305,11 +341,11 @@ gst_audio_cd_src_set_device (GstAudioCdSrc * src, const gchar * device)
if (strncmp (device, "/dev/dsk", 8) == 0) { if (strncmp (device, "/dev/dsk", 8) == 0) {
gchar *rdsk_value; gchar *rdsk_value;
rdsk_value = g_strdup_printf ("/dev/rdsk%s", device + 8); rdsk_value = g_strdup_printf ("/dev/rdsk%s", device + 8);
src->device = g_strdup (rdsk_value); src->priv->device = g_strdup (rdsk_value);
g_free (rdsk_value); g_free (rdsk_value);
} else { } else {
#endif #endif
src->device = g_strdup (device); src->priv->device = g_strdup (device);
#ifdef __sun #ifdef __sun
} }
#endif #endif
@ -325,7 +361,7 @@ gst_audio_cd_src_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case ARG_MODE:{ case ARG_MODE:{
src->mode = g_value_get_enum (value); src->priv->mode = g_value_get_enum (value);
break; break;
} }
case ARG_DEVICE:{ case ARG_DEVICE:{
@ -337,22 +373,22 @@ gst_audio_cd_src_set_property (GObject * object, guint prop_id,
case ARG_TRACK:{ case ARG_TRACK:{
guint track = g_value_get_uint (value); guint track = g_value_get_uint (value);
if (src->num_tracks > 0 && track > src->num_tracks) { if (src->priv->num_tracks > 0 && track > src->priv->num_tracks) {
g_warning ("Invalid track %u", track); g_warning ("Invalid track %u", track);
} else if (track > 0 && src->tracks != NULL) { } else if (track > 0 && src->priv->tracks != NULL) {
src->cur_sector = src->tracks[track - 1].start; src->priv->cur_sector = src->priv->tracks[track - 1].start;
src->uri_track = track; src->priv->uri_track = track;
} else { } else {
src->uri_track = track; /* seek will be done in start() */ src->priv->uri_track = track; /* seek will be done in start() */
} }
break; break;
} }
case ARG_TOC_OFFSET:{ case ARG_TOC_OFFSET:{
src->toc_offset = g_value_get_int (value); src->priv->toc_offset = g_value_get_int (value);
break; break;
} }
case ARG_TOC_BIAS:{ case ARG_TOC_BIAS:{
src->toc_bias = g_value_get_boolean (value); src->priv->toc_bias = g_value_get_boolean (value);
break; break;
} }
default:{ default:{
@ -375,10 +411,10 @@ gst_audio_cd_src_get_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case ARG_MODE: case ARG_MODE:
g_value_set_enum (value, src->mode); g_value_set_enum (value, src->priv->mode);
break; break;
case ARG_DEVICE:{ case ARG_DEVICE:{
if (src->device == NULL && klass->get_default_device != NULL) { if (src->priv->device == NULL && klass->get_default_device != NULL) {
gchar *d = klass->get_default_device (src); gchar *d = klass->get_default_device (src);
if (d != NULL) { if (d != NULL) {
@ -387,25 +423,25 @@ gst_audio_cd_src_get_property (GObject * object, guint prop_id,
break; break;
} }
} }
if (src->device == NULL) if (src->priv->device == NULL)
g_value_set_string (value, DEFAULT_DEVICE); g_value_set_string (value, DEFAULT_DEVICE);
else else
g_value_set_string (value, src->device); g_value_set_string (value, src->priv->device);
break; break;
} }
case ARG_TRACK:{ case ARG_TRACK:{
if (src->num_tracks <= 0 && src->uri_track > 0) { if (src->priv->num_tracks <= 0 && src->priv->uri_track > 0) {
g_value_set_uint (value, src->uri_track); g_value_set_uint (value, src->priv->uri_track);
} else { } else {
g_value_set_uint (value, src->cur_track + 1); g_value_set_uint (value, src->priv->cur_track + 1);
} }
break; break;
} }
case ARG_TOC_OFFSET: case ARG_TOC_OFFSET:
g_value_set_int (value, src->toc_offset); g_value_set_int (value, src->priv->toc_offset);
break; break;
case ARG_TOC_BIAS: case ARG_TOC_BIAS:
g_value_set_boolean (value, src->toc_bias); g_value_set_boolean (value, src->priv->toc_bias);
break; break;
default:{ default:{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -421,8 +457,9 @@ gst_audio_cd_src_get_track_from_sector (GstAudioCdSrc * src, gint sector)
{ {
gint i; gint i;
for (i = 0; i < src->num_tracks; ++i) { for (i = 0; i < src->priv->num_tracks; ++i) {
if (sector >= src->tracks[i].start && sector <= src->tracks[i].end) if (sector >= src->priv->tracks[i].start
&& sector <= src->priv->tracks[i].end)
return i; return i;
} }
return -1; return -1;
@ -449,12 +486,12 @@ gst_audio_cd_src_convert (GstAudioCdSrc * src, GstFormat src_format,
if (src_format == track_format) { if (src_format == track_format) {
if (!started) if (!started)
goto not_started; goto not_started;
if (src_val < 0 || src_val >= src->num_tracks) { if (src_val < 0 || src_val >= src->priv->num_tracks) {
GST_DEBUG_OBJECT (src, "track number %d out of bounds", (gint) src_val); GST_DEBUG_OBJECT (src, "track number %d out of bounds", (gint) src_val);
goto wrong_value; goto wrong_value;
} }
src_format = GST_FORMAT_DEFAULT; src_format = GST_FORMAT_DEFAULT;
src_val = src->tracks[src_val].start * SAMPLES_PER_SECTOR; src_val = src->priv->tracks[src_val].start * SAMPLES_PER_SECTOR;
} else if (src_format == sector_format) { } else if (src_format == sector_format) {
src_format = GST_FORMAT_DEFAULT; src_format = GST_FORMAT_DEFAULT;
src_val = src_val * SAMPLES_PER_SECTOR; src_val = src_val * SAMPLES_PER_SECTOR;
@ -590,23 +627,24 @@ gst_audio_cd_src_query (GstBaseSrc * basesrc, GstQuery * query)
if (!started) if (!started)
return FALSE; return FALSE;
g_assert (src->tracks != NULL); g_assert (src->priv->tracks != NULL);
if (dest_format == track_format) { if (dest_format == track_format) {
GST_LOG_OBJECT (src, "duration: %d tracks", src->num_tracks); GST_LOG_OBJECT (src, "duration: %d tracks", src->priv->num_tracks);
gst_query_set_duration (query, track_format, src->num_tracks); gst_query_set_duration (query, track_format, src->priv->num_tracks);
return TRUE; return TRUE;
} }
if (src->cur_track < 0 || src->cur_track >= src->num_tracks) if (src->priv->cur_track < 0
|| src->priv->cur_track >= src->priv->num_tracks)
return FALSE; return FALSE;
if (src->mode == GST_AUDIO_CD_SRC_MODE_NORMAL) { if (src->priv->mode == GST_AUDIO_CD_SRC_MODE_NORMAL) {
sectors = src->tracks[src->cur_track].end - sectors = src->priv->tracks[src->priv->cur_track].end -
src->tracks[src->cur_track].start + 1; src->priv->tracks[src->priv->cur_track].start + 1;
} else { } else {
sectors = src->tracks[src->num_tracks - 1].end - sectors = src->priv->tracks[src->priv->num_tracks - 1].end -
src->tracks[0].start + 1; src->priv->tracks[0].start + 1;
} }
/* ... and convert into final format */ /* ... and convert into final format */
@ -631,21 +669,24 @@ gst_audio_cd_src_query (GstBaseSrc * basesrc, GstQuery * query)
if (!started) if (!started)
return FALSE; return FALSE;
g_assert (src->tracks != NULL); g_assert (src->priv->tracks != NULL);
if (dest_format == track_format) { if (dest_format == track_format) {
GST_LOG_OBJECT (src, "position: track %d", src->cur_track); GST_LOG_OBJECT (src, "position: track %d", src->priv->cur_track);
gst_query_set_position (query, track_format, src->cur_track); gst_query_set_position (query, track_format, src->priv->cur_track);
return TRUE; return TRUE;
} }
if (src->cur_track < 0 || src->cur_track >= src->num_tracks) if (src->priv->cur_track < 0
|| src->priv->cur_track >= src->priv->num_tracks)
return FALSE; return FALSE;
if (src->mode == GST_AUDIO_CD_SRC_MODE_NORMAL) { if (src->priv->mode == GST_AUDIO_CD_SRC_MODE_NORMAL) {
pos_sector = src->cur_sector - src->tracks[src->cur_track].start; pos_sector =
src->priv->cur_sector -
src->priv->tracks[src->priv->cur_track].start;
} else { } else {
pos_sector = src->cur_sector - src->tracks[0].start; pos_sector = src->priv->cur_sector - src->priv->tracks[0].start;
} }
if (!gst_audio_cd_src_convert (src, sector_format, pos_sector, if (!gst_audio_cd_src_convert (src, sector_format, pos_sector,
@ -705,22 +746,23 @@ gst_audio_cd_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
} }
/* we should only really be called when open */ /* we should only really be called when open */
g_assert (src->cur_track >= 0 && src->cur_track < src->num_tracks); g_assert (src->priv->cur_track >= 0
&& src->priv->cur_track < src->priv->num_tracks);
switch (src->mode) { switch (src->priv->mode) {
case GST_AUDIO_CD_SRC_MODE_NORMAL: case GST_AUDIO_CD_SRC_MODE_NORMAL:
seek_sector += src->tracks[src->cur_track].start; seek_sector += src->priv->tracks[src->priv->cur_track].start;
break; break;
case GST_AUDIO_CD_SRC_MODE_CONTINUOUS: case GST_AUDIO_CD_SRC_MODE_CONTINUOUS:
seek_sector += src->tracks[0].start; seek_sector += src->priv->tracks[0].start;
break; break;
default: default:
g_return_val_if_reached (FALSE); g_return_val_if_reached (FALSE);
} }
src->cur_sector = (gint) seek_sector; src->priv->cur_sector = (gint) seek_sector;
GST_DEBUG_OBJECT (src, "seek'd to sector %d", src->cur_sector); GST_DEBUG_OBJECT (src, "seek'd to sector %d", src->priv->cur_sector);
return TRUE; return TRUE;
} }
@ -737,9 +779,9 @@ gst_audio_cd_src_handle_track_seek (GstAudioCdSrc * src, gdouble rate,
gint64 start_time = -1; gint64 start_time = -1;
gint64 stop_time = -1; gint64 stop_time = -1;
if (src->mode != GST_AUDIO_CD_SRC_MODE_CONTINUOUS) { if (src->priv->mode != GST_AUDIO_CD_SRC_MODE_CONTINUOUS) {
GST_DEBUG_OBJECT (src, "segment seek in track format is only " GST_DEBUG_OBJECT (src, "segment seek in track format is only "
"supported in CONTINUOUS mode, not in mode %d", src->mode); "supported in CONTINUOUS mode, not in mode %d", src->priv->mode);
return FALSE; return FALSE;
} }
@ -754,7 +796,8 @@ gst_audio_cd_src_handle_track_seek (GstAudioCdSrc * src, gdouble rate,
break; break;
case GST_SEEK_TYPE_END: case GST_SEEK_TYPE_END:
if (!gst_audio_cd_src_convert (src, track_format, if (!gst_audio_cd_src_convert (src, track_format,
src->num_tracks - start - 1, GST_FORMAT_TIME, &start_time)) { src->priv->num_tracks - start - 1, GST_FORMAT_TIME,
&start_time)) {
GST_DEBUG_OBJECT (src, "cannot convert track %d to time", GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
(gint) start); (gint) start);
return FALSE; return FALSE;
@ -779,7 +822,8 @@ gst_audio_cd_src_handle_track_seek (GstAudioCdSrc * src, gdouble rate,
break; break;
case GST_SEEK_TYPE_END: case GST_SEEK_TYPE_END:
if (!gst_audio_cd_src_convert (src, track_format, if (!gst_audio_cd_src_convert (src, track_format,
src->num_tracks - stop - 1, GST_FORMAT_TIME, &stop_time)) { src->priv->num_tracks - stop - 1, GST_FORMAT_TIME,
&stop_time)) {
GST_DEBUG_OBJECT (src, "cannot convert track %d to time", GST_DEBUG_OBJECT (src, "cannot convert track %d to time",
(gint) stop); (gint) stop);
return FALSE; return FALSE;
@ -816,20 +860,20 @@ gst_audio_cd_src_handle_track_seek (GstAudioCdSrc * src, gdouble rate,
GST_WARNING_OBJECT (src, "ignoring stop seek type (expected NONE)"); GST_WARNING_OBJECT (src, "ignoring stop seek type (expected NONE)");
} }
if (start < 0 || start >= src->num_tracks) { if (start < 0 || start >= src->priv->num_tracks) {
GST_DEBUG_OBJECT (src, "invalid track %" G_GINT64_FORMAT, start); GST_DEBUG_OBJECT (src, "invalid track %" G_GINT64_FORMAT, start);
return FALSE; return FALSE;
} }
GST_DEBUG_OBJECT (src, "seeking to track %" G_GINT64_FORMAT, start + 1); GST_DEBUG_OBJECT (src, "seeking to track %" G_GINT64_FORMAT, start + 1);
src->cur_sector = src->tracks[start].start; src->priv->cur_sector = src->priv->tracks[start].start;
GST_DEBUG_OBJECT (src, "starting at sector %d", src->cur_sector); GST_DEBUG_OBJECT (src, "starting at sector %d", src->priv->cur_sector);
if (src->cur_track != start) { if (src->priv->cur_track != start) {
src->cur_track = (gint) start; src->priv->cur_track = (gint) start;
src->uri_track = -1; src->priv->uri_track = -1;
src->prev_track = -1; src->priv->prev_track = -1;
gst_audio_cd_src_update_duration (src); gst_audio_cd_src_update_duration (src);
} else { } else {
@ -917,19 +961,19 @@ gst_audio_cd_src_uri_get_uri (GstURIHandler * handler)
/* FIXME: can we get rid of all that here and just return a copy of the /* FIXME: can we get rid of all that here and just return a copy of the
* existing URI perhaps? */ * existing URI perhaps? */
g_free (src->uri); g_free (src->priv->uri);
if (GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_FLAG_STARTED)) { if (GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_FLAG_STARTED)) {
src->uri = src->priv->uri =
g_strdup_printf ("cdda://%s#%d", src->device, g_strdup_printf ("cdda://%s#%d", src->priv->device,
(src->uri_track > 0) ? src->uri_track : 1); (src->priv->uri_track > 0) ? src->priv->uri_track : 1);
} else { } else {
src->uri = g_strdup ("cdda://1"); src->priv->uri = g_strdup ("cdda://1");
} }
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
return g_strdup (src->uri); return g_strdup (src->priv->uri);
} }
/* Note: gst_element_make_from_uri() might call us with just 'cdda://' as /* Note: gst_element_make_from_uri() might call us with just 'cdda://' as
@ -949,7 +993,7 @@ gst_audio_cd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
location = uri + 7; location = uri + 7;
track_number = g_strrstr (location, "#"); track_number = g_strrstr (location, "#");
src->uri_track = 0; src->priv->uri_track = 0;
/* FIXME 0.11: ignore URI fragments that look like device paths for /* FIXME 0.11: ignore URI fragments that look like device paths for
* the benefit of rhythmbox and possibly other applications. * the benefit of rhythmbox and possibly other applications.
*/ */
@ -961,28 +1005,30 @@ gst_audio_cd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
device = gst_uri_get_location (nuri); device = gst_uri_get_location (nuri);
gst_audio_cd_src_set_device (src, device); gst_audio_cd_src_set_device (src, device);
g_free (device); g_free (device);
src->uri_track = strtol (track_number + 1, NULL, 10); src->priv->uri_track = strtol (track_number + 1, NULL, 10);
g_free (nuri); g_free (nuri);
} else { } else {
if (*location == '\0') if (*location == '\0')
src->uri_track = 1; src->priv->uri_track = 1;
else else
src->uri_track = strtol (location, NULL, 10); src->priv->uri_track = strtol (location, NULL, 10);
} }
if (src->uri_track < 1) if (src->priv->uri_track < 1)
goto failed; goto failed;
if (src->num_tracks > 0 if (src->priv->num_tracks > 0
&& src->tracks != NULL && src->uri_track > src->num_tracks) && src->priv->tracks != NULL
&& src->priv->uri_track > src->priv->num_tracks)
goto failed; goto failed;
if (src->uri_track > 0 && src->tracks != NULL) { if (src->priv->uri_track > 0 && src->priv->tracks != NULL) {
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
gst_pad_send_event (GST_BASE_SRC_PAD (src), gst_pad_send_event (GST_BASE_SRC_PAD (src),
gst_event_new_seek (1.0, track_format, GST_SEEK_FLAG_FLUSH, gst_event_new_seek (1.0, track_format, GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, src->uri_track - 1, GST_SEEK_TYPE_NONE, -1)); GST_SEEK_TYPE_SET, src->priv->uri_track - 1, GST_SEEK_TYPE_NONE,
-1));
} else { } else {
/* seek will be done in start() */ /* seek will be done in start() */
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
@ -1034,11 +1080,12 @@ gst_audio_cd_src_add_track (GstAudioCdSrc * src, GstAudioCdSrcTrack * track)
g_return_val_if_fail (track->num > 0, FALSE); g_return_val_if_fail (track->num > 0, FALSE);
GST_DEBUG_OBJECT (src, "adding track %2u (%2u) [%6u-%6u] [%5s], tags: %" GST_DEBUG_OBJECT (src, "adding track %2u (%2u) [%6u-%6u] [%5s], tags: %"
GST_PTR_FORMAT, src->num_tracks + 1, track->num, track->start, GST_PTR_FORMAT, src->priv->num_tracks + 1, track->num, track->start,
track->end, (track->is_audio) ? "AUDIO" : "DATA ", track->tags); track->end, (track->is_audio) ? "AUDIO" : "DATA ", track->tags);
if (src->num_tracks > 0) { if (src->priv->num_tracks > 0) {
guint end_of_previous_track = src->tracks[src->num_tracks - 1].end; guint end_of_previous_track =
src->priv->tracks[src->priv->num_tracks - 1].end;
if (track->start <= end_of_previous_track) { if (track->start <= end_of_previous_track) {
GST_WARNING ("track %2u overlaps with previous tracks", track->num); GST_WARNING ("track %2u overlaps with previous tracks", track->num);
@ -1048,9 +1095,10 @@ gst_audio_cd_src_add_track (GstAudioCdSrc * src, GstAudioCdSrcTrack * track)
GST_OBJECT_LOCK (src); GST_OBJECT_LOCK (src);
++src->num_tracks; ++src->priv->num_tracks;
src->tracks = g_renew (GstAudioCdSrcTrack, src->tracks, src->num_tracks); src->priv->tracks =
src->tracks[src->num_tracks - 1] = *track; g_renew (GstAudioCdSrcTrack, src->priv->tracks, src->priv->num_tracks);
src->priv->tracks[src->priv->num_tracks - 1] = *track;
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
@ -1107,16 +1155,19 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
s = g_string_new (NULL); s = g_string_new (NULL);
leadout_sector = src->tracks[src->num_tracks - 1].end + 1 + CD_MSF_OFFSET; leadout_sector =
src->priv->tracks[src->priv->num_tracks - 1].end + 1 + CD_MSF_OFFSET;
/* generate SHA digest */ /* generate SHA digest */
sha = g_checksum_new (G_CHECKSUM_SHA1); sha = g_checksum_new (G_CHECKSUM_SHA1);
g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[0].num); g_snprintf (tmp, sizeof (tmp), "%02X", src->priv->tracks[0].num);
g_string_append_printf (s, "%02X", src->tracks[0].num); g_string_append_printf (s, "%02X", src->priv->tracks[0].num);
g_checksum_update (sha, (guchar *) tmp, 2); g_checksum_update (sha, (guchar *) tmp, 2);
g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[src->num_tracks - 1].num); g_snprintf (tmp, sizeof (tmp), "%02X",
g_string_append_printf (s, " %02X", src->tracks[src->num_tracks - 1].num); src->priv->tracks[src->priv->num_tracks - 1].num);
g_string_append_printf (s, " %02X",
src->priv->tracks[src->priv->num_tracks - 1].num);
g_checksum_update (sha, (guchar *) tmp, 2); g_checksum_update (sha, (guchar *) tmp, 2);
g_snprintf (tmp, sizeof (tmp), "%08X", leadout_sector); g_snprintf (tmp, sizeof (tmp), "%08X", leadout_sector);
@ -1124,8 +1175,8 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
g_checksum_update (sha, (guchar *) tmp, 8); g_checksum_update (sha, (guchar *) tmp, 8);
for (i = 0; i < 99; i++) { for (i = 0; i < 99; i++) {
if (i < src->num_tracks) { if (i < src->priv->num_tracks) {
guint frame_offset = src->tracks[i].start + CD_MSF_OFFSET; guint frame_offset = src->priv->tracks[i].start + CD_MSF_OFFSET;
g_snprintf (tmp, sizeof (tmp), "%08X", frame_offset); g_snprintf (tmp, sizeof (tmp), "%08X", frame_offset);
g_string_append_printf (s, " %08X", frame_offset); g_string_append_printf (s, " %08X", frame_offset);
@ -1142,15 +1193,15 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
g_checksum_free (sha); g_checksum_free (sha);
i = strlen (ptr); i = strlen (ptr);
g_assert (i < sizeof (src->mb_discid) + 1); g_assert (i < sizeof (src->priv->mb_discid) + 1);
memcpy (src->mb_discid, ptr, i); memcpy (src->priv->mb_discid, ptr, i);
src->mb_discid[i] = '\0'; src->priv->mb_discid[i] = '\0';
free (ptr); free (ptr);
/* Replace '/', '+' and '=' by '_', '.' and '-' as specified on /* Replace '/', '+' and '=' by '_', '.' and '-' as specified on
* http://musicbrainz.org/doc/DiscIDCalculation * http://musicbrainz.org/doc/DiscIDCalculation
*/ */
for (ptr = src->mb_discid; *ptr != '\0'; ptr++) { for (ptr = src->priv->mb_discid; *ptr != '\0'; ptr++) {
if (*ptr == '/') if (*ptr == '/')
*ptr = '_'; *ptr = '_';
else if (*ptr == '+') else if (*ptr == '+')
@ -1159,11 +1210,11 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
*ptr = '-'; *ptr = '-';
} }
GST_DEBUG_OBJECT (src, "musicbrainz-discid = %s", src->mb_discid); GST_DEBUG_OBJECT (src, "musicbrainz-discid = %s", src->priv->mb_discid);
GST_DEBUG_OBJECT (src, "musicbrainz-discid-full = %s", s->str); GST_DEBUG_OBJECT (src, "musicbrainz-discid-full = %s", s->str);
gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE, gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_CDDA_MUSICBRAINZ_DISCID, src->mb_discid, GST_TAG_CDDA_MUSICBRAINZ_DISCID, src->priv->mb_discid,
GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL, s->str, NULL); GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL, s->str, NULL);
g_string_free (s, TRUE); g_string_free (s, TRUE);
@ -1204,22 +1255,23 @@ gst_audio_cd_src_calculate_cddb_id (GstAudioCdSrc * src)
/* FIXME: do we use offsets and duration of ALL tracks (data + audio) /* FIXME: do we use offsets and duration of ALL tracks (data + audio)
* for the CDDB ID calculation, or only audio tracks? */ * for the CDDB ID calculation, or only audio tracks? */
for (i = 0; i < src->num_tracks; ++i) { for (i = 0; i < src->priv->num_tracks; ++i) {
if (1) { /* src->tracks[i].is_audio) { */ if (1) { /* src->priv->tracks[i].is_audio) { */
if (num_audio_tracks == 0) { if (num_audio_tracks == 0) {
first_sector = src->tracks[i].start + CD_MSF_OFFSET; first_sector = src->priv->tracks[i].start + CD_MSF_OFFSET;
} }
last_sector = src->tracks[i].end + CD_MSF_OFFSET + 1; last_sector = src->priv->tracks[i].end + CD_MSF_OFFSET + 1;
++num_audio_tracks; ++num_audio_tracks;
lba_to_msf (src->tracks[i].start + CD_MSF_OFFSET, NULL, NULL, NULL, lba_to_msf (src->priv->tracks[i].start + CD_MSF_OFFSET, NULL, NULL, NULL,
&secs); &secs);
len_secs = (src->tracks[i].end - src->tracks[i].start + 1) / 75; len_secs =
(src->priv->tracks[i].end - src->priv->tracks[i].start + 1) / 75;
GST_DEBUG_OBJECT (src, "track %02u: lsn %6u (%02u:%02u), " GST_DEBUG_OBJECT (src, "track %02u: lsn %6u (%02u:%02u), "
"length: %u seconds (%02u:%02u)", "length: %u seconds (%02u:%02u)",
num_audio_tracks, src->tracks[i].start + CD_MSF_OFFSET, num_audio_tracks, src->priv->tracks[i].start + CD_MSF_OFFSET,
secs / 60, secs % 60, len_secs, len_secs / 60, len_secs % 60); secs / 60, secs % 60, len_secs, len_secs / 60, len_secs % 60);
id += cddb_sum (secs); id += cddb_sum (secs);
@ -1227,10 +1279,10 @@ gst_audio_cd_src_calculate_cddb_id (GstAudioCdSrc * src)
} }
} }
/* first_sector = src->tracks[0].start + CD_MSF_OFFSET; */ /* first_sector = src->priv->tracks[0].start + CD_MSF_OFFSET; */
lba_to_msf (first_sector, NULL, NULL, NULL, &start_secs); lba_to_msf (first_sector, NULL, NULL, NULL, &start_secs);
/* last_sector = src->tracks[src->num_tracks-1].end + CD_MSF_OFFSET; */ /* last_sector = src->priv->tracks[src->priv->num_tracks-1].end + CD_MSF_OFFSET; */
lba_to_msf (last_sector, NULL, NULL, NULL, &end_secs); lba_to_msf (last_sector, NULL, NULL, NULL, &end_secs);
GST_DEBUG_OBJECT (src, "first_sector = %u = %u secs (%02u:%02u)", GST_DEBUG_OBJECT (src, "first_sector = %u = %u secs (%02u:%02u)",
@ -1244,17 +1296,18 @@ gst_audio_cd_src_calculate_cddb_id (GstAudioCdSrc * src)
"lengths = %u seconds (%02u:%02u)", t, t / 60, t % 60, total_secs, "lengths = %u seconds (%02u:%02u)", t, t / 60, t % 60, total_secs,
total_secs / 60, total_secs % 60); total_secs / 60, total_secs % 60);
src->discid = ((id % 0xff) << 24 | t << 8 | num_audio_tracks); src->priv->discid = ((id % 0xff) << 24 | t << 8 | num_audio_tracks);
s = g_string_new (NULL); s = g_string_new (NULL);
g_string_append_printf (s, "%08x", src->discid); g_string_append_printf (s, "%08x", src->priv->discid);
gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE, gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_CDDA_CDDB_DISCID, s->str, NULL); GST_TAG_CDDA_CDDB_DISCID, s->str, NULL);
g_string_append_printf (s, " %u", src->num_tracks); g_string_append_printf (s, " %u", src->priv->num_tracks);
for (i = 0; i < src->num_tracks; ++i) { for (i = 0; i < src->priv->num_tracks; ++i) {
g_string_append_printf (s, " %u", src->tracks[i].start + CD_MSF_OFFSET); g_string_append_printf (s, " %u",
src->priv->tracks[i].start + CD_MSF_OFFSET);
} }
g_string_append_printf (s, " %u", t); g_string_append_printf (s, " %u", t);
@ -1272,21 +1325,22 @@ gst_audio_cd_src_add_tags (GstAudioCdSrc * src)
gint i; gint i;
/* fill in details for each track */ /* fill in details for each track */
for (i = 0; i < src->num_tracks; ++i) { for (i = 0; i < src->priv->num_tracks; ++i) {
gint64 duration; gint64 duration;
guint num_sectors; guint num_sectors;
if (src->tracks[i].tags == NULL) if (src->priv->tracks[i].tags == NULL)
src->tracks[i].tags = gst_tag_list_new_empty (); src->priv->tracks[i].tags = gst_tag_list_new_empty ();
num_sectors = src->tracks[i].end - src->tracks[i].start + 1; num_sectors = src->priv->tracks[i].end - src->priv->tracks[i].start + 1;
gst_audio_cd_src_convert (src, sector_format, num_sectors, gst_audio_cd_src_convert (src, sector_format, num_sectors,
GST_FORMAT_TIME, &duration); GST_FORMAT_TIME, &duration);
gst_tag_list_add (src->tracks[i].tags, gst_tag_list_add (src->priv->tracks[i].tags,
GST_TAG_MERGE_REPLACE, GST_TAG_MERGE_REPLACE,
GST_TAG_TRACK_NUMBER, i + 1, GST_TAG_TRACK_NUMBER, i + 1,
GST_TAG_TRACK_COUNT, src->num_tracks, GST_TAG_DURATION, duration, NULL); GST_TAG_TRACK_COUNT, src->priv->num_tracks, GST_TAG_DURATION, duration,
NULL);
} }
/* now fill in per-album tags and include each track's tags /* now fill in per-album tags and include each track's tags
@ -1299,11 +1353,11 @@ gst_audio_cd_src_add_tags (GstAudioCdSrc * src)
* the track number ?? *//////////////////////////////////////// * the track number ?? *////////////////////////////////////////
gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE, gst_tag_list_add (src->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_TRACK_COUNT, src->num_tracks, NULL); GST_TAG_TRACK_COUNT, src->priv->num_tracks, NULL);
#if 0 #if 0
for (i = 0; i < src->num_tracks; ++i) { for (i = 0; i < src->priv->num_tracks; ++i) {
gst_tag_list_add (src->tags, GST_TAG_MERGE_APPEND, gst_tag_list_add (src->tags, GST_TAG_MERGE_APPEND,
GST_TAG_CDDA_TRACK_TAGS, src->tracks[i].tags, NULL); GST_TAG_CDDA_TRACK_TAGS, src->priv->tracks[i].tags, NULL);
} }
#endif #endif
@ -1315,11 +1369,11 @@ gst_audio_cd_src_add_index_associations (GstAudioCdSrc * src)
{ {
gint i; gint i;
for (i = 0; i < src->num_tracks; i++) { for (i = 0; i < src->priv->num_tracks; i++) {
gint64 sector; gint64 sector;
sector = src->tracks[i].start; sector = src->priv->tracks[i].start;
gst_index_add_association (src->index, src->index_id, GST_ASSOCIATION_FLAG_KEY_UNIT, track_format, i, /* here we count from 0 */ gst_index_add_association (src->priv->index, src->priv->index_id, GST_ASSOCIATION_FLAG_KEY_UNIT, track_format, i, /* here we count from 0 */
sector_format, sector, sector_format, sector,
GST_FORMAT_TIME, GST_FORMAT_TIME,
(gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100), (gint64) (((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100),
@ -1335,22 +1389,22 @@ gst_audio_cd_src_set_index (GstElement * element, GstIndex * index)
GstIndex *old; GstIndex *old;
GST_OBJECT_LOCK (element); GST_OBJECT_LOCK (element);
old = src->index; old = src->priv->index;
if (old == index) { if (old == index) {
GST_OBJECT_UNLOCK (element); GST_OBJECT_UNLOCK (element);
return; return;
} }
if (index) if (index)
gst_object_ref (index); gst_object_ref (index);
src->index = index; src->priv->index = index;
GST_OBJECT_UNLOCK (element); GST_OBJECT_UNLOCK (element);
if (old) if (old)
gst_object_unref (old); gst_object_unref (old);
if (index) { if (index) {
gst_index_get_writer_id (index, GST_OBJECT (src), &src->index_id); gst_index_get_writer_id (index, GST_OBJECT (src), &src->priv->index_id);
gst_index_add_format (index, src->index_id, track_format); gst_index_add_format (index, src->priv->index_id, track_format);
gst_index_add_format (index, src->index_id, sector_format); gst_index_add_format (index, src->priv->index_id, sector_format);
} }
} }
@ -1362,7 +1416,7 @@ gst_audio_cd_src_get_index (GstElement * element)
GstIndex *index; GstIndex *index;
GST_OBJECT_LOCK (element); GST_OBJECT_LOCK (element);
if ((index = src->index)) if ((index = src->priv->index))
gst_object_ref (index); gst_object_ref (index);
GST_OBJECT_UNLOCK (element); GST_OBJECT_UNLOCK (element);
@ -1395,13 +1449,13 @@ gst_audio_cd_src_start (GstBaseSrc * basesrc)
gboolean ret; gboolean ret;
gchar *device = NULL; gchar *device = NULL;
src->discid = 0; src->priv->discid = 0;
src->mb_discid[0] = '\0'; src->priv->mb_discid[0] = '\0';
g_assert (klass->open != NULL); g_assert (klass->open != NULL);
if (src->device != NULL) { if (src->priv->device != NULL) {
device = g_strdup (src->device); device = g_strdup (src->priv->device);
} else if (klass->get_default_device != NULL) { } else if (klass->get_default_device != NULL) {
device = klass->get_default_device (src); device = klass->get_default_device (src);
} }
@ -1420,7 +1474,7 @@ gst_audio_cd_src_start (GstBaseSrc * basesrc)
if (!ret) if (!ret)
goto open_failed; goto open_failed;
if (src->num_tracks == 0 || src->tracks == NULL) if (src->priv->num_tracks == 0 || src->priv->tracks == NULL)
goto no_tracks; goto no_tracks;
/* need to calculate disc IDs before we ditch the data tracks */ /* need to calculate disc IDs before we ditch the data tracks */
@ -1429,45 +1483,46 @@ gst_audio_cd_src_start (GstBaseSrc * basesrc)
#if 0 #if 0
/* adjust sector offsets if necessary */ /* adjust sector offsets if necessary */
if (src->toc_bias) { if (src->priv->toc_bias) {
src->toc_offset -= src->tracks[0].start; src->priv->toc_offset -= src->priv->tracks[0].start;
} }
for (i = 0; i < src->num_tracks; ++i) { for (i = 0; i < src->priv->num_tracks; ++i) {
src->tracks[i].start += src->toc_offset; src->priv->tracks[i].start += src->priv->toc_offset;
src->tracks[i].end += src->toc_offset; src->priv->tracks[i].end += src->priv->toc_offset;
} }
#endif #endif
/* now that we calculated the various disc IDs, /* now that we calculated the various disc IDs,
* sort the data tracks to end and ignore them */ * sort the data tracks to end and ignore them */
src->num_all_tracks = src->num_tracks; src->priv->num_all_tracks = src->priv->num_tracks;
g_qsort_with_data (src->tracks, src->num_tracks, g_qsort_with_data (src->priv->tracks, src->priv->num_tracks,
sizeof (GstAudioCdSrcTrack), gst_audio_cd_src_track_sort_func, NULL); sizeof (GstAudioCdSrcTrack), gst_audio_cd_src_track_sort_func, NULL);
while (src->num_tracks > 0 && !src->tracks[src->num_tracks - 1].is_audio) while (src->priv->num_tracks > 0
--src->num_tracks; && !src->priv->tracks[src->priv->num_tracks - 1].is_audio)
--src->priv->num_tracks;
if (src->num_tracks == 0) if (src->priv->num_tracks == 0)
goto no_tracks; goto no_tracks;
gst_audio_cd_src_add_tags (src); gst_audio_cd_src_add_tags (src);
if (src->index && GST_INDEX_IS_WRITABLE (src->index)) if (src->priv->index && GST_INDEX_IS_WRITABLE (src->priv->index))
gst_audio_cd_src_add_index_associations (src); gst_audio_cd_src_add_index_associations (src);
src->cur_track = 0; src->priv->cur_track = 0;
src->prev_track = -1; src->priv->prev_track = -1;
if (src->uri_track > 0 && src->uri_track <= src->num_tracks) { if (src->priv->uri_track > 0 && src->priv->uri_track <= src->priv->num_tracks) {
GST_LOG_OBJECT (src, "seek to track %d", src->uri_track); GST_LOG_OBJECT (src, "seek to track %d", src->priv->uri_track);
src->cur_track = src->uri_track - 1; src->priv->cur_track = src->priv->uri_track - 1;
src->uri_track = -1; src->priv->uri_track = -1;
src->mode = GST_AUDIO_CD_SRC_MODE_NORMAL; src->priv->mode = GST_AUDIO_CD_SRC_MODE_NORMAL;
} }
src->cur_sector = src->tracks[src->cur_track].start; src->priv->cur_sector = src->priv->tracks[src->priv->cur_track].start;
GST_LOG_OBJECT (src, "starting at sector %d", src->cur_sector); GST_LOG_OBJECT (src, "starting at sector %d", src->priv->cur_sector);
gst_audio_cd_src_update_duration (src); gst_audio_cd_src_update_duration (src);
@ -1494,19 +1549,19 @@ no_tracks:
static void static void
gst_audio_cd_src_clear_tracks (GstAudioCdSrc * src) gst_audio_cd_src_clear_tracks (GstAudioCdSrc * src)
{ {
if (src->tracks != NULL) { if (src->priv->tracks != NULL) {
gint i; gint i;
for (i = 0; i < src->num_all_tracks; ++i) { for (i = 0; i < src->priv->num_all_tracks; ++i) {
if (src->tracks[i].tags) if (src->priv->tracks[i].tags)
gst_tag_list_free (src->tracks[i].tags); gst_tag_list_free (src->priv->tracks[i].tags);
} }
g_free (src->tracks); g_free (src->priv->tracks);
src->tracks = NULL; src->priv->tracks = NULL;
} }
src->num_tracks = 0; src->priv->num_tracks = 0;
src->num_all_tracks = 0; src->priv->num_all_tracks = 0;
} }
static gboolean static gboolean
@ -1526,8 +1581,8 @@ gst_audio_cd_src_stop (GstBaseSrc * basesrc)
src->tags = NULL; src->tags = NULL;
} }
src->prev_track = -1; src->priv->prev_track = -1;
src->cur_track = -1; src->priv->cur_track = -1;
return TRUE; return TRUE;
} }
@ -1547,47 +1602,51 @@ gst_audio_cd_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
g_assert (klass->read_sector != NULL); g_assert (klass->read_sector != NULL);
switch (src->mode) { switch (src->priv->mode) {
case GST_AUDIO_CD_SRC_MODE_NORMAL: case GST_AUDIO_CD_SRC_MODE_NORMAL:
eos = (src->cur_sector > src->tracks[src->cur_track].end); eos =
(src->priv->cur_sector > src->priv->tracks[src->priv->cur_track].end);
break; break;
case GST_AUDIO_CD_SRC_MODE_CONTINUOUS: case GST_AUDIO_CD_SRC_MODE_CONTINUOUS:
eos = (src->cur_sector > src->tracks[src->num_tracks - 1].end); eos =
src->cur_track = gst_audio_cd_src_get_track_from_sector (src, (src->priv->cur_sector >
src->cur_sector); src->priv->tracks[src->priv->num_tracks - 1].end);
src->priv->cur_track =
gst_audio_cd_src_get_track_from_sector (src, src->priv->cur_sector);
break; break;
default: default:
g_return_val_if_reached (GST_FLOW_ERROR); g_return_val_if_reached (GST_FLOW_ERROR);
} }
if (eos) { if (eos) {
src->prev_track = -1; src->priv->prev_track = -1;
GST_DEBUG_OBJECT (src, "EOS at sector %d, cur_track=%d, mode=%d", GST_DEBUG_OBJECT (src, "EOS at sector %d, cur_track=%d, mode=%d",
src->cur_sector, src->cur_track, src->mode); src->priv->cur_sector, src->priv->cur_track, src->priv->mode);
/* base class will send EOS for us */ /* base class will send EOS for us */
return GST_FLOW_EOS; return GST_FLOW_EOS;
} }
if (src->prev_track != src->cur_track) { if (src->priv->prev_track != src->priv->cur_track) {
GstTagList *tags; GstTagList *tags;
tags = gst_tag_list_merge (src->tags, src->tracks[src->cur_track].tags, tags =
GST_TAG_MERGE_REPLACE); gst_tag_list_merge (src->tags,
src->priv->tracks[src->priv->cur_track].tags, GST_TAG_MERGE_REPLACE);
GST_LOG_OBJECT (src, "announcing tags: %" GST_PTR_FORMAT, tags); GST_LOG_OBJECT (src, "announcing tags: %" GST_PTR_FORMAT, tags);
gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tags)); gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tags));
src->prev_track = src->cur_track; src->priv->prev_track = src->priv->cur_track;
gst_audio_cd_src_update_duration (src); gst_audio_cd_src_update_duration (src);
g_object_notify (G_OBJECT (src), "track"); g_object_notify (G_OBJECT (src), "track");
} }
GST_LOG_OBJECT (src, "asking for sector %u", src->cur_sector); GST_LOG_OBJECT (src, "asking for sector %u", src->priv->cur_sector);
buf = klass->read_sector (src, src->cur_sector); buf = klass->read_sector (src, src->priv->cur_sector);
if (buf == NULL) { if (buf == NULL) {
GST_WARNING_OBJECT (src, "failed to read sector %u", src->cur_sector); GST_WARNING_OBJECT (src, "failed to read sector %u", src->priv->cur_sector);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -1597,12 +1656,12 @@ gst_audio_cd_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
position = (GstClockTime) qry_position; position = (GstClockTime) qry_position;
++src->cur_sector; ++src->priv->cur_sector;
if (gst_pad_query_position (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME, if (gst_pad_query_position (GST_BASE_SRC_PAD (src), GST_FORMAT_TIME,
&next_ts)) { &next_ts)) {
duration = (GstClockTime) (next_ts - qry_position); duration = (GstClockTime) (next_ts - qry_position);
} }
--src->cur_sector; --src->priv->cur_sector;
} }
/* fallback duration: 4 bytes per sample, 44100 samples per second */ /* fallback duration: 4 bytes per sample, 44100 samples per second */
@ -1615,9 +1674,9 @@ gst_audio_cd_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
GST_BUFFER_DURATION (buf) = duration; GST_BUFFER_DURATION (buf) = duration;
GST_LOG_OBJECT (src, "pushing sector %d with timestamp %" GST_TIME_FORMAT, GST_LOG_OBJECT (src, "pushing sector %d with timestamp %" GST_TIME_FORMAT,
src->cur_sector, GST_TIME_ARGS (position)); src->priv->cur_sector, GST_TIME_ARGS (position));
++src->cur_sector; ++src->priv->cur_sector;
*buffer = buf; *buffer = buf;

View file

@ -35,6 +35,7 @@ G_BEGIN_DECLS
typedef struct _GstAudioCdSrc GstAudioCdSrc; typedef struct _GstAudioCdSrc GstAudioCdSrc;
typedef struct _GstAudioCdSrcClass GstAudioCdSrcClass; typedef struct _GstAudioCdSrcClass GstAudioCdSrcClass;
typedef struct _GstAudioCdSrcTrack GstAudioCdSrcTrack; typedef struct _GstAudioCdSrcTrack GstAudioCdSrcTrack;
typedef struct _GstAudioCdSrcPrivate GstAudioCdSrcPrivate;
/** /**
* GstAudioCdSrcMode: * GstAudioCdSrcMode:
@ -80,30 +81,7 @@ struct _GstAudioCdSrc {
GstTagList *tags; /* tags that apply to all tracks */ GstTagList *tags; /* tags that apply to all tracks */
/*< private >*/ /*< private >*/
GstAudioCdSrcMode mode; GstAudioCdSrcPrivate *priv;
gchar *device;
guint num_tracks;
guint num_all_tracks;
GstAudioCdSrcTrack *tracks;
gint cur_track; /* current track (starting from 0) */
gint prev_track; /* current track last time */
gint cur_sector; /* current sector */
gint seek_sector; /* -1 or sector to seek to */
gint uri_track;
gchar *uri;
guint32 discid; /* cddb disc id (for unit test) */
gchar mb_discid[32]; /* musicbrainz discid */
GstIndex *index;
gint index_id;
gint toc_offset;
gboolean toc_bias;
/*< private >*/ /*< private >*/
guint _gst_reserved1[GST_PADDING/2]; guint _gst_reserved1[GST_PADDING/2];