update debugging to current system

Original commit message from CVS:
update debugging to current system
This commit is contained in:
Benjamin Otte 2003-10-28 12:12:55 +00:00
parent d2cf080210
commit 08337d5a24
2 changed files with 52 additions and 74 deletions

View file

@ -88,18 +88,6 @@ GstElementDetails gst_filesrc_details = {
#define DEFAULT_BLOCKSIZE 4*1024 #define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024 #define DEFAULT_MMAPSIZE 4*1024*1024
#ifdef G_HAVE_ISO_VARARGS
/* #define fs_print(...) g_print(__VA_ARGS__) */
#define fs_print(...)
#elif defined(G_HAVE_GNUC_VARARGS)
/* #define fs_print(format,args...) g_print(format, ## args) */
#define fs_print(format,args...)
#endif
/* FileSrc signals and args */ /* FileSrc signals and args */
enum { enum {
/* FILL ME */ /* FILL ME */
@ -305,7 +293,7 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->mapsize = g_value_get_ulong (value); src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize"); g_object_notify (G_OBJECT (src), "mmapsize");
} else { } else {
GST_INFO ( "invalid mapsize, must a multiple of pagesize, which is %d", GST_INFO_OBJECT (src, "invalid mapsize, must a multiple of pagesize, which is %d",
src->pagesize); src->pagesize);
} }
break; break;
@ -355,8 +343,8 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
{ {
GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf)); GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf));
fs_print ("freeing mmap()d buffer at %d+%d\n", GST_LOG_OBJECT (src, "freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u",
GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf)); GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
/* remove the buffer from the list of available mmap'd regions */ /* remove the buffer from the list of available mmap'd regions */
g_mutex_lock (src->map_regions_lock); g_mutex_lock (src->map_regions_lock);
@ -375,7 +363,7 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf)); munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
/* cast to unsigned long, since there's no gportable way to print /* cast to unsigned long, since there's no gportable way to print
* guint64 as hex */ * guint64 as hex */
GST_DEBUG ( "unmapped region %08lx+%08lx at %p", GST_LOG_OBJECT (src, "unmapped region %08lx+%08lx at %p",
(unsigned long) GST_BUFFER_OFFSET (buf), (unsigned long) GST_BUFFER_OFFSET (buf),
(unsigned long) GST_BUFFER_MAXSIZE (buf), (unsigned long) GST_BUFFER_MAXSIZE (buf),
GST_BUFFER_DATA (buf)); GST_BUFFER_DATA (buf));
@ -394,7 +382,7 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
g_return_val_if_fail (offset >= 0, NULL); g_return_val_if_fail (offset >= 0, NULL);
fs_print ("mapping region %08llx+%08lx from file into memory\n",offset,(unsigned long)size); GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",offset,(unsigned long)size);
mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset); mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
if (mmapregion == NULL) { if (mmapregion == NULL) {
@ -402,11 +390,11 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
return NULL; return NULL;
} }
else if (mmapregion == MAP_FAILED) { else if (mmapregion == MAP_FAILED) {
GST_DEBUG ("mmap (0x%08lx, %d, 0x%llx) : %s", GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s",
(unsigned long)size, src->fd, offset, strerror (errno)); (unsigned long)size, src->fd, offset, strerror (errno));
return NULL; return NULL;
} }
GST_DEBUG ( "mapped region %08lx+%08lx from file into memory at %p", GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
(unsigned long)offset, (unsigned long)size, mmapregion); (unsigned long)offset, (unsigned long)size, mmapregion);
/* time to allocate a new mapbuf */ /* time to allocate a new mapbuf */
@ -522,7 +510,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* if the end is before the mapend, the buffer is in current mmap region... */ /* if the end is before the mapend, the buffer is in current mmap region... */
/* ('cause by definition if readend is in the buffer, so's readstart) */ /* ('cause by definition if readend is in the buffer, so's readstart) */
if (readend <= mapend) { if (readend <= mapend) {
fs_print ("read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf\n", GST_LOG_OBJECT (src, "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
src->curoffset, readsize, mapstart, mapsize); src->curoffset, readsize, mapstart, mapsize);
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
readsize); readsize);
@ -530,8 +518,8 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* if the start actually is within the current mmap region, map an overlap buffer */ /* if the start actually is within the current mmap region, map an overlap buffer */
} else if (src->curoffset < mapend) { } else if (src->curoffset < mapend) {
fs_print ("read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap\n", GST_LOG_OBJECT (src, "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
src->curoffset, readsize, mapstart, mapsize); (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
@ -545,8 +533,8 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* either the read buffer overlaps the start of the mmap region */ /* either the read buffer overlaps the start of the mmap region */
/* or the read buffer fully contains the current mmap region */ /* or the read buffer fully contains the current mmap region */
/* either way, it's really not relevant, we just create a new region anyway*/ /* either way, it's really not relevant, we just create a new region anyway*/
fs_print ("read buf %llu+%d starts before mapbuf %d+%d, but overlaps it\n", GST_LOG_OBJECT (src, "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
src->curoffset,readsize, mapstart, mapsize); (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
@ -555,7 +543,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* then deal with the case where the read buffer is totally outside */ /* then deal with the case where the read buffer is totally outside */
if (buf == NULL) { if (buf == NULL) {
/* first check to see if there's a map that covers the right region already */ /* first check to see if there's a map that covers the right region already */
fs_print ("searching for mapbuf to cover %llu+%d\n",src->curoffset,readsize); GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d",src->curoffset,readsize);
region.offset = src->curoffset; region.offset = src->curoffset;
region.size = readsize; region.size = readsize;
map = g_tree_search (src->map_regions, map = g_tree_search (src->map_regions,
@ -564,7 +552,8 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* if we found an exact match, subbuffer it */ /* if we found an exact match, subbuffer it */
if (map != NULL) { if (map != NULL) {
fs_print ("found mapbuf at %d+%d, creating subbuffer\n",GST_BUFFER_OFFSET(map),GST_BUFFER_SIZE(map)); GST_LOG_OBJECT (src, "found mapbuf at %"G_GUINT64_FORMAT"+%u, creating subbuffer",
GST_BUFFER_OFFSET (map), GST_BUFFER_SIZE (map));
buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize); buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize);
GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_OFFSET (buf) = src->curoffset;
@ -572,7 +561,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
} else { } else {
/* if the read buffer crosses a mmap region boundary, create a one-off region */ /* if the read buffer crosses a mmap region boundary, create a one-off region */
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) { if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
fs_print ("read buf %llu+%d crosses a %d-byte boundary, creating a one-off\n", GST_LOG_OBJECT (src, "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
src->curoffset,readsize,src->mapsize); src->curoffset,readsize,src->mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
@ -583,7 +572,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
size_t mapsize; size_t mapsize;
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize); off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
fs_print ("read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering\n", GST_LOG_OBJECT (src, "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
src->curoffset, readsize, nextmap, src->mapsize); src->curoffset, readsize, nextmap, src->mapsize);
/* first, we're done with the old mapbuf */ /* first, we're done with the old mapbuf */
gst_buffer_unref(src->mapbuf); gst_buffer_unref(src->mapbuf);
@ -591,7 +580,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* double the mapsize as long as the readsize is smaller */ /* double the mapsize as long as the readsize is smaller */
while (readsize - (src->curoffset - nextmap) > mapsize) { while (readsize - (src->curoffset - nextmap) > mapsize) {
fs_print ("readsize smaller then mapsize %08x %d\n", readsize, mapsize); GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d", readsize, mapsize);
mapsize <<=1; mapsize <<=1;
} }
/* create a new one */ /* create a new one */
@ -664,7 +653,7 @@ gst_filesrc_get (GstPad *pad)
GstEvent *event; GstEvent *event;
src->seek_happened = FALSE; src->seek_happened = FALSE;
GST_DEBUG ("filesrc sending discont"); GST_DEBUG_OBJECT (src, "sending discont");
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL); event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
src->need_flush = FALSE; src->need_flush = FALSE;
return GST_DATA (event); return GST_DATA (event);
@ -672,13 +661,13 @@ gst_filesrc_get (GstPad *pad)
/* check for flush */ /* check for flush */
if (src->need_flush) { if (src->need_flush) {
src->need_flush = FALSE; src->need_flush = FALSE;
GST_DEBUG ("filesrc sending flush"); GST_DEBUG_OBJECT (src, "sending flush");
return GST_DATA (gst_event_new_flush ()); return GST_DATA (gst_event_new_flush ());
} }
/* check for EOF */ /* check for EOF */
if (src->curoffset == src->filelen) { if (src->curoffset == src->filelen) {
GST_DEBUG ("filesrc eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT,
src->curoffset, src->filelen); src->curoffset, src->filelen);
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
@ -697,7 +686,7 @@ gst_filesrc_open_file (GstFileSrc *src)
{ {
g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE); g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE);
GST_DEBUG ( "opening file %s",src->filename); GST_INFO_OBJECT (src, "opening file %s",src->filename);
/* open the file */ /* open the file */
src->fd = open (src->filename, O_RDONLY); src->fd = open (src->filename, O_RDONLY);
@ -829,7 +818,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
{ {
GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad)); GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad));
GST_DEBUG ( "event %d", GST_EVENT_TYPE (event)); GST_DEBUG_OBJECT (src, "event %d", GST_EVENT_TYPE (event));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
@ -847,19 +836,19 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
if (offset > src->filelen) if (offset > src->filelen)
goto error; goto error;
src->curoffset = offset; src->curoffset = offset;
GST_DEBUG ( "seek set pending to %" G_GINT64_FORMAT, src->curoffset); GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, src->curoffset);
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_METHOD_CUR:
if (offset + src->curoffset > src->filelen) if (offset + src->curoffset > src->filelen)
goto error; goto error;
src->curoffset += offset; src->curoffset += offset;
GST_DEBUG ( "seek cur pending to %" G_GINT64_FORMAT, src->curoffset); GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, src->curoffset);
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_METHOD_END:
if (ABS (offset) > src->filelen) if (ABS (offset) > src->filelen)
goto error; goto error;
src->curoffset = src->filelen - ABS (offset); src->curoffset = src->filelen - ABS (offset);
GST_DEBUG ( "seek end pending to %" G_GINT64_FORMAT, src->curoffset); GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, src->curoffset);
break; break;
default: default:
goto error; goto error;

View file

@ -88,18 +88,6 @@ GstElementDetails gst_filesrc_details = {
#define DEFAULT_BLOCKSIZE 4*1024 #define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024 #define DEFAULT_MMAPSIZE 4*1024*1024
#ifdef G_HAVE_ISO_VARARGS
/* #define fs_print(...) g_print(__VA_ARGS__) */
#define fs_print(...)
#elif defined(G_HAVE_GNUC_VARARGS)
/* #define fs_print(format,args...) g_print(format, ## args) */
#define fs_print(format,args...)
#endif
/* FileSrc signals and args */ /* FileSrc signals and args */
enum { enum {
/* FILL ME */ /* FILL ME */
@ -305,7 +293,7 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->mapsize = g_value_get_ulong (value); src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize"); g_object_notify (G_OBJECT (src), "mmapsize");
} else { } else {
GST_INFO ( "invalid mapsize, must a multiple of pagesize, which is %d", GST_INFO_OBJECT (src, "invalid mapsize, must a multiple of pagesize, which is %d",
src->pagesize); src->pagesize);
} }
break; break;
@ -355,8 +343,8 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
{ {
GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf)); GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf));
fs_print ("freeing mmap()d buffer at %d+%d\n", GST_LOG_OBJECT (src, "freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u",
GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf)); GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
/* remove the buffer from the list of available mmap'd regions */ /* remove the buffer from the list of available mmap'd regions */
g_mutex_lock (src->map_regions_lock); g_mutex_lock (src->map_regions_lock);
@ -375,7 +363,7 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf)); munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
/* cast to unsigned long, since there's no gportable way to print /* cast to unsigned long, since there's no gportable way to print
* guint64 as hex */ * guint64 as hex */
GST_DEBUG ( "unmapped region %08lx+%08lx at %p", GST_LOG_OBJECT (src, "unmapped region %08lx+%08lx at %p",
(unsigned long) GST_BUFFER_OFFSET (buf), (unsigned long) GST_BUFFER_OFFSET (buf),
(unsigned long) GST_BUFFER_MAXSIZE (buf), (unsigned long) GST_BUFFER_MAXSIZE (buf),
GST_BUFFER_DATA (buf)); GST_BUFFER_DATA (buf));
@ -394,7 +382,7 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
g_return_val_if_fail (offset >= 0, NULL); g_return_val_if_fail (offset >= 0, NULL);
fs_print ("mapping region %08llx+%08lx from file into memory\n",offset,(unsigned long)size); GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",offset,(unsigned long)size);
mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset); mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
if (mmapregion == NULL) { if (mmapregion == NULL) {
@ -402,11 +390,11 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
return NULL; return NULL;
} }
else if (mmapregion == MAP_FAILED) { else if (mmapregion == MAP_FAILED) {
GST_DEBUG ("mmap (0x%08lx, %d, 0x%llx) : %s", GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s",
(unsigned long)size, src->fd, offset, strerror (errno)); (unsigned long)size, src->fd, offset, strerror (errno));
return NULL; return NULL;
} }
GST_DEBUG ( "mapped region %08lx+%08lx from file into memory at %p", GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
(unsigned long)offset, (unsigned long)size, mmapregion); (unsigned long)offset, (unsigned long)size, mmapregion);
/* time to allocate a new mapbuf */ /* time to allocate a new mapbuf */
@ -522,7 +510,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* if the end is before the mapend, the buffer is in current mmap region... */ /* if the end is before the mapend, the buffer is in current mmap region... */
/* ('cause by definition if readend is in the buffer, so's readstart) */ /* ('cause by definition if readend is in the buffer, so's readstart) */
if (readend <= mapend) { if (readend <= mapend) {
fs_print ("read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf\n", GST_LOG_OBJECT (src, "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf",
src->curoffset, readsize, mapstart, mapsize); src->curoffset, readsize, mapstart, mapsize);
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart,
readsize); readsize);
@ -530,8 +518,8 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* if the start actually is within the current mmap region, map an overlap buffer */ /* if the start actually is within the current mmap region, map an overlap buffer */
} else if (src->curoffset < mapend) { } else if (src->curoffset < mapend) {
fs_print ("read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap\n", GST_LOG_OBJECT (src, "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap",
src->curoffset, readsize, mapstart, mapsize); (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
@ -545,8 +533,8 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* either the read buffer overlaps the start of the mmap region */ /* either the read buffer overlaps the start of the mmap region */
/* or the read buffer fully contains the current mmap region */ /* or the read buffer fully contains the current mmap region */
/* either way, it's really not relevant, we just create a new region anyway*/ /* either way, it's really not relevant, we just create a new region anyway*/
fs_print ("read buf %llu+%d starts before mapbuf %d+%d, but overlaps it\n", GST_LOG_OBJECT (src, "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it",
src->curoffset,readsize, mapstart, mapsize); (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
@ -555,7 +543,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* then deal with the case where the read buffer is totally outside */ /* then deal with the case where the read buffer is totally outside */
if (buf == NULL) { if (buf == NULL) {
/* first check to see if there's a map that covers the right region already */ /* first check to see if there's a map that covers the right region already */
fs_print ("searching for mapbuf to cover %llu+%d\n",src->curoffset,readsize); GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d",src->curoffset,readsize);
region.offset = src->curoffset; region.offset = src->curoffset;
region.size = readsize; region.size = readsize;
map = g_tree_search (src->map_regions, map = g_tree_search (src->map_regions,
@ -564,7 +552,8 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* if we found an exact match, subbuffer it */ /* if we found an exact match, subbuffer it */
if (map != NULL) { if (map != NULL) {
fs_print ("found mapbuf at %d+%d, creating subbuffer\n",GST_BUFFER_OFFSET(map),GST_BUFFER_SIZE(map)); GST_LOG_OBJECT (src, "found mapbuf at %"G_GUINT64_FORMAT"+%u, creating subbuffer",
GST_BUFFER_OFFSET (map), GST_BUFFER_SIZE (map));
buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize); buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize);
GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_OFFSET (buf) = src->curoffset;
@ -572,7 +561,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
} else { } else {
/* if the read buffer crosses a mmap region boundary, create a one-off region */ /* if the read buffer crosses a mmap region boundary, create a one-off region */
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) { if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
fs_print ("read buf %llu+%d crosses a %d-byte boundary, creating a one-off\n", GST_LOG_OBJECT (src, "read buf %llu+%d crosses a %d-byte boundary, creating a one-off",
src->curoffset,readsize,src->mapsize); src->curoffset,readsize,src->mapsize);
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
if (buf == NULL) if (buf == NULL)
@ -583,7 +572,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
size_t mapsize; size_t mapsize;
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize); off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
fs_print ("read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering\n", GST_LOG_OBJECT (src, "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering",
src->curoffset, readsize, nextmap, src->mapsize); src->curoffset, readsize, nextmap, src->mapsize);
/* first, we're done with the old mapbuf */ /* first, we're done with the old mapbuf */
gst_buffer_unref(src->mapbuf); gst_buffer_unref(src->mapbuf);
@ -591,7 +580,7 @@ gst_filesrc_get_mmap (GstFileSrc *src)
/* double the mapsize as long as the readsize is smaller */ /* double the mapsize as long as the readsize is smaller */
while (readsize - (src->curoffset - nextmap) > mapsize) { while (readsize - (src->curoffset - nextmap) > mapsize) {
fs_print ("readsize smaller then mapsize %08x %d\n", readsize, mapsize); GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d", readsize, mapsize);
mapsize <<=1; mapsize <<=1;
} }
/* create a new one */ /* create a new one */
@ -664,7 +653,7 @@ gst_filesrc_get (GstPad *pad)
GstEvent *event; GstEvent *event;
src->seek_happened = FALSE; src->seek_happened = FALSE;
GST_DEBUG ("filesrc sending discont"); GST_DEBUG_OBJECT (src, "sending discont");
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL); event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL);
src->need_flush = FALSE; src->need_flush = FALSE;
return GST_DATA (event); return GST_DATA (event);
@ -672,13 +661,13 @@ gst_filesrc_get (GstPad *pad)
/* check for flush */ /* check for flush */
if (src->need_flush) { if (src->need_flush) {
src->need_flush = FALSE; src->need_flush = FALSE;
GST_DEBUG ("filesrc sending flush"); GST_DEBUG_OBJECT (src, "sending flush");
return GST_DATA (gst_event_new_flush ()); return GST_DATA (gst_event_new_flush ());
} }
/* check for EOF */ /* check for EOF */
if (src->curoffset == src->filelen) { if (src->curoffset == src->filelen) {
GST_DEBUG ("filesrc eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT, GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT,
src->curoffset, src->filelen); src->curoffset, src->filelen);
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));
return GST_DATA (gst_event_new (GST_EVENT_EOS)); return GST_DATA (gst_event_new (GST_EVENT_EOS));
@ -697,7 +686,7 @@ gst_filesrc_open_file (GstFileSrc *src)
{ {
g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE); g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE);
GST_DEBUG ( "opening file %s",src->filename); GST_INFO_OBJECT (src, "opening file %s",src->filename);
/* open the file */ /* open the file */
src->fd = open (src->filename, O_RDONLY); src->fd = open (src->filename, O_RDONLY);
@ -829,7 +818,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
{ {
GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad)); GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad));
GST_DEBUG ( "event %d", GST_EVENT_TYPE (event)); GST_DEBUG_OBJECT (src, "event %d", GST_EVENT_TYPE (event));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
@ -847,19 +836,19 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
if (offset > src->filelen) if (offset > src->filelen)
goto error; goto error;
src->curoffset = offset; src->curoffset = offset;
GST_DEBUG ( "seek set pending to %" G_GINT64_FORMAT, src->curoffset); GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, src->curoffset);
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_METHOD_CUR:
if (offset + src->curoffset > src->filelen) if (offset + src->curoffset > src->filelen)
goto error; goto error;
src->curoffset += offset; src->curoffset += offset;
GST_DEBUG ( "seek cur pending to %" G_GINT64_FORMAT, src->curoffset); GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, src->curoffset);
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_METHOD_END:
if (ABS (offset) > src->filelen) if (ABS (offset) > src->filelen)
goto error; goto error;
src->curoffset = src->filelen - ABS (offset); src->curoffset = src->filelen - ABS (offset);
GST_DEBUG ( "seek end pending to %" G_GINT64_FORMAT, src->curoffset); GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, src->curoffset);
break; break;
default: default:
goto error; goto error;