[easytag] Remove use of GDataInputStream
- From: Ekaterina Gerasimova <egerasimov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Remove use of GDataInputStream
- Date: Tue, 28 May 2013 20:19:39 +0000 (UTC)
commit 470bce483dccef811b154e8219c02e57ce1efcad
Author: Ekaterina Gerasimova <kittykat3756 gmail com>
Date: Tue May 28 20:33:08 2013 +0100
Remove use of GDataInputStream
None of the features of GDataInputStream over GFileInputStream were
used, so it was unnecessary.
src/ogg_tag.c | 43 +++++++++++++++++--------------------------
src/vcedit.c | 51 ++++++++++++++++++++++++++-------------------------
src/vcedit.h | 2 +-
3 files changed, 44 insertions(+), 52 deletions(-)
---
diff --git a/src/ogg_tag.c b/src/ogg_tag.c
index a7f622e..724d93c 100644
--- a/src/ogg_tag.c
+++ b/src/ogg_tag.c
@@ -124,7 +124,6 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
{
GFile *file;
GFileInputStream *istream;
- GDataInputStream *distream;
vcedit_state *state;
vorbis_comment *vc;
gchar *string = NULL;
@@ -148,20 +147,18 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
return FALSE;
}
- distream = g_data_input_stream_new (G_INPUT_STREAM (istream));
-
{
// Skip the id3v2 tag
guchar tmp_id3[4];
gulong id3v2size;
// Check if there is an ID3v2 tag...
- if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET, NULL, error))
+ if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET, NULL, error))
{
goto err;
}
- if (g_input_stream_read (G_INPUT_STREAM (distream), tmp_id3, 4, NULL,
+ if (g_input_stream_read (G_INPUT_STREAM (istream), tmp_id3, 4, NULL,
error) == 4)
{
// Calculate ID3v2 length
@@ -169,19 +166,19 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
{
// id3v2 tag skipeer $49 44 33 yy yy xx zz zz zz zz [zz size]
/* Size is 6-9 position */
- if (!g_seekable_seek (G_SEEKABLE (distream), 2, G_SEEK_CUR,
+ if (!g_seekable_seek (G_SEEKABLE (istream), 2, G_SEEK_CUR,
NULL, error))
{
goto err;
}
- if (g_input_stream_read (G_INPUT_STREAM (distream), tmp_id3, 4,
+ if (g_input_stream_read (G_INPUT_STREAM (istream), tmp_id3, 4,
NULL, error) == 4)
{
id3v2size = 10 + ( (long)(tmp_id3[3]) | ((long)(tmp_id3[2]) << 7)
| ((long)(tmp_id3[1]) << 14) | ((long)(tmp_id3[0]) << 21) );
- if (!g_seekable_seek (G_SEEKABLE (distream), id3v2size,
+ if (!g_seekable_seek (G_SEEKABLE (istream), id3v2size,
G_SEEK_SET, NULL, error))
{
goto err;
@@ -189,21 +186,21 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
Log_Print(LOG_ERROR,_("Warning: The Ogg Vorbis file '%s' contains an ID3v2
tag."),filename_utf8);
}
- else if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET,
+ else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
NULL, error))
{
goto err;
}
}
- else if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET,
+ else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
NULL, error))
{
goto err;
}
}
- else if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET,
+ else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
NULL, error))
{
goto err;
@@ -213,7 +210,6 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
g_assert (error == NULL || *error == NULL);
- g_object_unref (distream);
g_object_unref (istream);
state = vcedit_new_state(); // Allocate memory for 'state'
@@ -618,7 +614,7 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
err:
g_assert (error == NULL || *error != NULL);
- g_object_unref (distream);
+ g_object_unref (istream);
g_object_unref (istream);
g_object_unref (file);
g_free(filename_utf8);
@@ -675,7 +671,6 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
gchar *basename_utf8;
GFile *file;
GFileInputStream *istream;
- GDataInputStream *distream;
vcedit_state *state;
vorbis_comment *vc;
gchar *string;
@@ -698,20 +693,18 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
return FALSE;
}
- distream = g_data_input_stream_new (G_INPUT_STREAM (istream));
-
{
// Skip the id3v2 tag
guchar tmp_id3[4];
gulong id3v2size;
// Check if there is an ID3v2 tag...
- if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET, NULL, error))
+ if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET, NULL, error))
{
goto err;
}
- if (g_input_stream_read (G_INPUT_STREAM (distream), tmp_id3, 4, NULL,
+ if (g_input_stream_read (G_INPUT_STREAM (istream), tmp_id3, 4, NULL,
error) == 4)
{
// Calculate ID3v2 length
@@ -719,19 +712,19 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
{
// id3v2 tag skipeer $49 44 33 yy yy xx zz zz zz zz [zz size]
/* Size is 6-9 position */
- if (!g_seekable_seek (G_SEEKABLE (distream), 2, G_SEEK_CUR,
+ if (!g_seekable_seek (G_SEEKABLE (istream), 2, G_SEEK_CUR,
NULL, error))
{
goto err;
}
- if (g_input_stream_read (G_INPUT_STREAM (distream), tmp_id3, 4,
+ if (g_input_stream_read (G_INPUT_STREAM (istream), tmp_id3, 4,
NULL, error) == 4)
{
id3v2size = 10 + ( (long)(tmp_id3[3]) | ((long)(tmp_id3[2]) << 7)
| ((long)(tmp_id3[1]) << 14) | ((long)(tmp_id3[0]) << 21) );
- if (!g_seekable_seek (G_SEEKABLE (distream), id3v2size,
+ if (!g_seekable_seek (G_SEEKABLE (istream), id3v2size,
G_SEEK_SET, NULL, error))
{
goto err;
@@ -739,21 +732,21 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
Log_Print(LOG_ERROR,_("Warning: The Ogg Vorbis file '%s' contains an ID3v2
tag."),filename_utf8);
}
- else if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET,
+ else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
NULL, error))
{
goto err;
}
}
- else if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET,
+ else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
NULL, error))
{
goto err;
}
}
- else if (!g_seekable_seek (G_SEEKABLE (distream), 0L, G_SEEK_SET,
+ else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
NULL, error))
{
goto err;
@@ -764,7 +757,6 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
g_assert (error == NULL || *error == NULL);
g_object_unref (istream);
- g_object_unref (distream);
state = vcedit_new_state(); // Allocate memory for 'state'
@@ -928,7 +920,6 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
err:
g_assert (error == NULL || *error != NULL);
- g_object_unref (distream);
g_object_unref (istream);
g_object_unref (file);
return FALSE;
diff --git a/src/vcedit.c b/src/vcedit.c
index f6e99bd..d0befe2 100644
--- a/src/vcedit.c
+++ b/src/vcedit.c
@@ -284,7 +284,7 @@ vcedit_open(vcedit_state *state, GFile *file, GError **error)
return FALSE;
}
- state->in = g_data_input_stream_new (G_INPUT_STREAM (istream));
+ state->in = istream;
state->oy = malloc(sizeof(ogg_sync_state));
ogg_sync_init(state->oy);
@@ -464,12 +464,10 @@ vcedit_open(vcedit_state *state, GFile *file, GError **error)
/* Headers are done! */
g_assert (error == NULL || *error == NULL);
- g_object_unref (istream);
return TRUE;
err:
g_assert (error == NULL || *error != NULL);
- g_object_unref (istream);
vcedit_clear_internals(state);
return FALSE;
}
@@ -490,7 +488,6 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
int bytes;
int needflush=0, needout=0;
GFileOutputStream *ostream;
- GDataOutputStream *dostream;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -503,8 +500,6 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
return FALSE;
}
- dostream = g_data_output_stream_new (G_OUTPUT_STREAM (ostream));
-
state->eosin = 0;
state->extrapage = 0;
@@ -532,7 +527,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
while((result = ogg_stream_flush(&streamout, &ogout)))
{
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.header,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.header,
ogout.header_len, NULL, error)
!= (gssize) ogout.header_len)
{
@@ -540,7 +535,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
goto cleanup;
}
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.body,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.body,
ogout.body_len, NULL, error)
!= (gssize) ogout.body_len)
{
@@ -553,7 +548,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
{
if(needflush)
{
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.header,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.header,
ogout.header_len, NULL, error)
!= (gssize) ogout.header_len)
{
@@ -561,7 +556,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
goto cleanup;
}
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.body,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.body,
ogout.body_len, NULL, error)
!= (gssize) ogout.body_len)
{
@@ -573,16 +568,18 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
{
if(ogg_stream_pageout(&streamout, &ogout))
{
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.header,
- ogout.header_len, NULL, error)
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream),
+ ogout.header, ogout.header_len,
+ NULL, error)
!= (gssize) ogout.header_len)
{
g_assert (error == NULL || *error != NULL);
goto cleanup;
}
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.body,
- ogout.body_len, NULL, error)
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream),
+ ogout.body, ogout.body_len, NULL,
+ error)
!= (gssize) ogout.body_len)
{
g_assert (error == NULL || *error != NULL);
@@ -637,7 +634,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
streamout.e_o_s = 1;
while(ogg_stream_flush(&streamout, &ogout))
{
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.header,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.header,
ogout.header_len, NULL, error)
!= (gssize) ogout.header_len)
{
@@ -645,7 +642,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
goto cleanup;
}
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.body,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.body,
ogout.body_len, NULL, error)
!= (gssize) ogout.body_len)
{
@@ -656,7 +653,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
if (state->extrapage)
{
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.header,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.header,
ogout.header_len, NULL, error)
!= (gssize) ogout.header_len)
{
@@ -664,7 +661,7 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
goto cleanup;
}
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.body,
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream), ogout.body,
ogout.body_len, NULL, error)
!= (gssize) ogout.body_len)
{
@@ -693,16 +690,18 @@ vcedit_write(vcedit_state *state, GFile *file, GError **error)
{
/* Don't bother going through the rest, we can just
* write the page out now */
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.header,
- ogout.header_len, NULL, error)
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream),
+ ogout.header, ogout.header_len,
+ NULL, error)
!= (gssize) ogout.header_len)
{
g_assert (error == NULL || *error != NULL);
goto cleanup;
}
- if (g_output_stream_write (G_OUTPUT_STREAM (dostream), ogout.body,
- ogout.body_len, NULL, error)
+ if (g_output_stream_write (G_OUTPUT_STREAM (ostream),
+ ogout.body, ogout.body_len, NULL,
+ error)
!= (gssize) ogout.body_len)
{
g_assert (error == NULL || *error != NULL);
@@ -740,12 +739,14 @@ cleanup:
if (!state->eosin)
{
- g_set_error (error, ET_OGG_ERROR, ET_OGG_ERROR_OUTPUT,
- "Error writing stream to output. Output stream may be corrupted or truncated");
+ if (!error)
+ {
+ g_set_error (error, ET_OGG_ERROR, ET_OGG_ERROR_OUTPUT,
+ "Error writing stream to output. Output stream may be corrupted or truncated");
+ }
}
g_object_unref (ostream);
- g_object_unref (dostream);
if (error == NULL || *error != NULL)
return FALSE;
diff --git a/src/vcedit.h b/src/vcedit.h
index 15321dd..e14d050 100644
--- a/src/vcedit.h
+++ b/src/vcedit.h
@@ -39,7 +39,7 @@ typedef struct {
SpeexHeader *si;
#endif
- GDataInputStream *in;
+ GFileInputStream *in;
long serial;
unsigned char *mainbuf;
unsigned char *bookbuf;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]