this works for me locally now, however it requires:

Original commit message from CVS:
this works for me locally now, however it requires:
- my local fix to implement gst_bytestream_tell (which I won't commit until events are redone)
- an audiofile patch which is already in debian but don't hold your breath for an upstream release
This commit is contained in:
Steve Baker 2002-04-21 15:12:34 +00:00
parent a175fe373c
commit 5c1e5be283

View file

@ -136,7 +136,7 @@ gst_afparse_class_init (GstAFParseClass *klass)
gobject_class->set_property = gst_afparse_set_property;
gobject_class->get_property = gst_afparse_get_property;
gstelement_class->change_state = gst_afparse_change_state;
/* gstelement_class->change_state = gst_afparse_change_state;*/
}
static void
@ -186,12 +186,13 @@ gst_afparse_loop(GstElement *element)
afparse = GST_AFPARSE(element);
afparse->vfile->closure = gst_bytestream_new(afparse->sinkpad);
if (gst_afparse_open_file (afparse)){
frames_to_bytes = afparse->channels * afparse->width / 8;
frames_per_read = afparse->frames_per_read;
bytes_per_read = frames_per_read * frames_to_bytes;
bufpool = gst_buffer_pool_get_default (bytes_per_read, 8);
do {
buf = gst_buffer_new_from_pool (bufpool, 0, 0);
GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
@ -213,9 +214,11 @@ gst_afparse_loop(GstElement *element)
afparse->timestamp += numframes * 1E9 / afparse->rate;
}
while (TRUE);
gst_afparse_close_file (afparse);
gst_buffer_pool_unref(bufpool);
}
gst_bytestream_destroy((GstByteStream*)afparse->vfile->closure);
gst_buffer_pool_unref(bufpool);
}
@ -340,7 +343,6 @@ gst_afparse_open_file (GstAFParse *afparse)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN), FALSE);
afparse->vfile->closure = gst_bytestream_new(afparse->srcpad);
/* open the file */
g_print("opening vfile %p\n", afparse->vfile);
@ -454,16 +456,28 @@ gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes)
{
GstByteStream *bs = (GstByteStream*)vfile->closure;
guint8 *bytes;
g_print("doing read\n");
bytes = gst_bytestream_peek_bytes(bs, nbytes);
if (!bytes){
/* handle events */
GstEvent *event = NULL;
guint32 waiting;
gchar *debug_bytes;
return 0;
while (!(bytes = gst_bytestream_peek_bytes(bs, nbytes))){
/* handle events */
gst_bytestream_get_status (bs, &waiting, &event);
if (!event) return 0;
if (event){
if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) return 0;
if (GST_EVENT_TYPE(event) == GST_EVENT_DISCONTINUOUS){
g_print("seek done\n");
}
}
}
memcpy(data, bytes, nbytes);
gst_bytestream_flush_fast(bs, nbytes);
data = bytes;
/*g_print("read %d bytes\n", nbytes);*/
return nbytes;
}
@ -472,10 +486,23 @@ gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative)
{
GstByteStream *bs = (GstByteStream*)vfile->closure;
GstSeekType type;
guint64 current_offset = gst_bytestream_tell(bs);
if (!is_relative){
if ((guint64)offset == current_offset) {
/* this seems to happen before every read - bad audiofile */
return offset;
}
type = GST_SEEK_BYTEOFFSET_SET;
}
else {
if (offset == 0) return current_offset;
type = GST_SEEK_BYTEOFFSET_CUR;
}
g_print("doing seek\n");
type = is_relative ? GST_SEEK_BYTEOFFSET_CUR : GST_SEEK_BYTEOFFSET_SET;
if (gst_bytestream_seek(bs, type, (gint64)offset)){
g_print("doing seek to %d\n", (gint)offset);
return offset;
}
return 0;
@ -510,10 +537,12 @@ gst_afparse_vf_destroy(AFvirtualfile *vfile)
static long
gst_afparse_vf_tell (AFvirtualfile *vfile)
{
/*GstByteStream *bs = (GstByteStream*)vfile->closure;*/
g_print("doing tell\n");
/* return gst_bytestream_tell(bs);*/
return 0;
GstByteStream *bs = (GstByteStream*)vfile->closure;
guint64 offset;
offset = gst_bytestream_tell(bs);
g_print("doing tell: %llu\n", offset);
return offset;
}
static GstCaps*