# HG changeset patch # User Tomasz Mon # Date 1185179941 -7200 # Node ID f8a449aa8a6f94850772b96bedcd240c3fba622f # Parent 670c41ca014763782656b3af1d7513546601bc25# Parent 0aaad77951c70abb245b6bb830b35aa2a13c9afd branch merge diff -r 670c41ca0147 -r f8a449aa8a6f src/audacious/input.c --- a/src/audacious/input.c Mon Jul 23 10:38:18 2007 +0200 +++ b/src/audacious/input.c Mon Jul 23 10:39:01 2007 +0200 @@ -371,6 +371,27 @@ if (tmp != NULL && g_ascii_isdigit(*(tmp + 1))) *tmp = '\0'; + /* CD-Audio uses cdda:// dummy paths, no filedescriptor handling for it */ + if (!g_strncasecmp(filename, "cdda://", 7)) { + for (node = get_input_list(); node != NULL; node = g_list_next(node)) + { + ip = INPUT_PLUGIN(node->data); + if (!ip || !input_is_enabled(ip->filename)) + continue; + if (ip->is_our_file != NULL) + ret = ip->is_our_file(filename_proxy); + if (ret > 0) + { + g_free(filename_proxy); + pr = g_new0(ProbeResult, 1); + pr->ip = ip; + return pr; + } + } + g_free(filename_proxy); + return NULL; + } + fd = vfs_buffered_file_new_from_uri(tmp_uri); g_free(tmp_uri); @@ -393,7 +414,7 @@ vfs_fclose(fd); pr = g_new0(ProbeResult, 1); - pr->ip = NULL; + pr->ip = ip; return pr; } diff -r 670c41ca0147 -r f8a449aa8a6f src/audacious/vfs.c --- a/src/audacious/vfs.c Mon Jul 23 10:38:18 2007 +0200 +++ b/src/audacious/vfs.c Mon Jul 23 10:39:01 2007 +0200 @@ -409,3 +409,75 @@ return in; } + +/** + * vfs_is_remote: + * @path: A path to test. + * + * Tests if a path is remote uri. + * + * Return value: TRUE if the file is remote, otherwise FALSE. + **/ +gboolean +vfs_is_remote(const gchar * path) +{ + VFSConstructor *vtable = NULL; + GList *node; + gchar *decpath; + + if (!path) + return FALSE; + + decpath = g_strdup(path); + + for (node = vfs_transports; node != NULL; node = g_list_next(node)) + { + VFSConstructor *vtptr = (VFSConstructor *) node->data; + + if (!strncasecmp(decpath, vtptr->uri_id, strlen(vtptr->uri_id))) + { + vtable = vtptr; + break; + } + } + + /* no transport vtable has been registered, bail. */ + if (vtable == NULL) + { + g_warning("could not open '%s', no transport plugin available", decpath); + return FALSE; + } + + /* check if vtable->uri_id is file:// or not, for now. */ + if(!strncasecmp("file://", vtable->uri_id, strlen(vtable->uri_id))) + return FALSE; + else + return TRUE; +} + +/** + * vfs_is_streaming: + * @file: A #VFSFile object to test. + * + * Tests if a file is associated to streaming. + * + * Return value: TRUE if the file is streaming, otherwise FALSE. + **/ +gboolean +vfs_is_streaming(VFSFile *file) +{ + off_t size = 0; + glong curpos; + + if(!file) + return FALSE; + + curpos = file->base->vfs_ftell_impl(file); + size = file->base->vfs_fsize_impl(file); + file->base->vfs_fseek_impl(file, curpos, SEEK_SET); + + if(size == -1) + return TRUE; + else + return FALSE; +} diff -r 670c41ca0147 -r f8a449aa8a6f src/audacious/vfs.h --- a/src/audacious/vfs.h Mon Jul 23 10:38:18 2007 +0200 +++ b/src/audacious/vfs.h Mon Jul 23 10:39:01 2007 +0200 @@ -132,6 +132,10 @@ extern void vfs_file_get_contents(const gchar *filename, gchar **buf, gsize *size); +extern gboolean vfs_is_remote(const gchar * path); + +extern gboolean vfs_is_streaming(VFSFile *file); + G_END_DECLS #endif /* VFS_H */ diff -r 670c41ca0147 -r f8a449aa8a6f src/audacious/vfs_buffered_file.c --- a/src/audacious/vfs_buffered_file.c Mon Jul 23 10:38:18 2007 +0200 +++ b/src/audacious/vfs_buffered_file.c Mon Jul 23 10:39:01 2007 +0200 @@ -116,14 +116,33 @@ vfs_fseek(handle->buffer, offset, whence); - /* if we go OOB, switch to live FD */ - if (vfs_ftell(handle->buffer) > ((VFSBuffer *) handle->buffer->handle)->size) + switch(whence) { - vfs_rewind(handle->buffer); - handle->which = TRUE; - vfs_fseek(handle->buffer, offset, whence); + case SEEK_END: + handle->which = TRUE; + vfs_fseek(handle->fd, offset, whence); + break; + case SEEK_CUR: + if (vfs_ftell(handle->buffer) + offset > ((VFSBuffer *) handle->buffer->handle)->size) + { + handle->which = TRUE; + vfs_fseek(handle->fd, offset, whence); + } + break; + case SEEK_SET: + default: + if (offset > ((VFSBuffer *) handle->buffer->handle)->size) + { + handle->which = TRUE; + vfs_fseek(handle->fd, offset, whence); + } + else + { + handle->which = FALSE; + vfs_fseek(handle->buffer, offset, whence); + } + break; } - return 0; } @@ -163,7 +182,7 @@ { VFSBufferedFile *handle = (VFSBufferedFile *) file->handle; - return vfs_fsize(handle->which == TRUE ? handle->fd : handle->buffer); + return vfs_fsize(handle->fd); } gchar * @@ -215,6 +234,7 @@ } sz = vfs_fread(fd->mem, 1, 40000, fd->fd); + vfs_rewind(fd->fd); if (!sz) {