# HG changeset patch # User nenolod # Date 1169436996 28800 # Node ID 631bd25d2380372e1266ce920e3494c706b4b106 # Parent 31d21ad70903c94c37e84c5ad8695c2b852ff944 [svn] - getc/ungetc emulation diff -r 31d21ad70903 -r 631bd25d2380 ChangeLog --- a/ChangeLog Sun Jan 21 16:08:19 2007 -0800 +++ b/ChangeLog Sun Jan 21 19:36:36 2007 -0800 @@ -1,3 +1,12 @@ +2007-01-22 00:08:19 +0000 Giacomo Lozito + revision [1072] + flac 113 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage) + trunk/src/flac113/configure.c | 21 ++++++++++++++++++--- + trunk/src/flac113/configure.h | 1 + + trunk/src/flac113/plugin.c | 15 +++++++++------ + 3 files changed, 28 insertions(+), 9 deletions(-) + + 2007-01-22 00:03:30 +0000 Giacomo Lozito revision [1070] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage) diff -r 31d21ad70903 -r 631bd25d2380 src/curl/curl.c --- a/src/curl/curl.c Sun Jan 21 16:08:19 2007 -0800 +++ b/src/curl/curl.c Sun Jan 21 19:36:36 2007 -0800 @@ -65,6 +65,8 @@ gchar *name; gchar *title; + + GSList *charstack; // getc/ungetc emulation --nenolod }; VFSConstructor curl_const; @@ -592,17 +594,41 @@ gint curl_vfs_getc_impl(VFSFile *stream) { + CurlHandle *handle = (CurlHandle *) stream->handle; gchar c; - if (curl_vfs_fread_impl(&c, 1, 1, stream) != 1) + + g_return_val_if_fail(handle != NULL, EOF); + + g_print("curl_vfs_getc reached\n"); + + if (handle->charstack != NULL) + { + c = GPOINTER_TO_INT(handle->charstack->data); + handle->charstack = g_slist_delete_link(handle->charstack, handle->charstack); + return c; + } + else if (curl_vfs_fread_impl(&c, 1, 1, stream) != 1) return -1; + return c; } gint curl_vfs_ungetc_impl(gint c, VFSFile *stream) { - g_print("Tried ungetc\n"); - return -1; + CurlHandle *handle = (CurlHandle *) stream->handle; + + g_return_val_if_fail(handle != NULL, EOF); + + g_print("curl_vfs_ungetc reached\n"); + + handle->charstack = g_slist_prepend(handle->charstack, GINT_TO_POINTER(c)); + + if (handle->charstack != NULL) + return c; + + /* only reached if there is an error... */ + return EOF; } gint