[beast/devel: 12/15] BSE: compile all gsl* files as C++ (except fft)
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 12/15] BSE: compile all gsl* files as C++ (except fft)
- Date: Sun, 16 Dec 2012 15:53:19 +0000 (UTC)
commit 9705fdac2b4546f8dc57fba74d04dee2f9e7086a
Author: Tim Janik <timj gnu org>
Date: Sun Dec 16 16:35:58 2012 +0100
BSE: compile all gsl* files as C++ (except fft)
bse/Makefile.am | 12 ++--
bse/{gslcommon.c => gslcommon.cc} | 10 +-
bse/{gsldatacache.c => gsldatacache.cc} | 4 +-
bse/{gsldatahandle-mad.c => gsldatahandle-mad.cc} | 23 +++---
...datahandle-vorbis.c => gsldatahandle-vorbis.cc} | 20 +++---
bse/{gsldatahandle.c => gsldatahandle.cc} | 28 +++---
bse/{gsldatautils.c => gsldatautils.cc} | 16 ++--
bse/{gslfilehash.c => gslfilehash.cc} | 12 ++--
bse/{gslfilter.c => gslfilter.cc} | 0
bse/{gslmagic.c => gslmagic.cc} | 84 ++++++++-----------
bse/gslmagic.h | 5 +-
bse/{gsloscillator-aux.c => gsloscillator-aux.cc} | 0
bse/{gsloscillator.c => gsloscillator.cc} | 4 +-
bse/{gslosctable.c => gslosctable.cc} | 85 +++++++++----------
bse/gslosctable.h | 3 +-
bse/{gslvorbis-cutter.c => gslvorbis-cutter.cc} | 14 ++--
bse/{gslvorbis-enc.c => gslvorbis-enc.cc} | 29 +++----
17 files changed, 165 insertions(+), 184 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index f365b60..151cd51 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -60,11 +60,11 @@ bse_public_headers = $(strip \
)
# BSE C & C++ sources
bse_sources = $(strip \
- gslfft.c gsloscillator.c gsldatahandle.c gslwavechunk.cc \
- gslfilter.c gslcommon.c \
- gsldatahandle-vorbis.c gslvorbis-enc.c gsldatacache.c gslvorbis-cutter.c \
- gsldatahandle-mad.c gslfilehash.c gsldatautils.c \
- gslwaveosc.cc gslosctable.c gslmagic.c \
+ gslfft.c gsloscillator.cc gsldatahandle.cc gslwavechunk.cc \
+ gslfilter.cc gslcommon.cc \
+ gsldatahandle-vorbis.cc gslvorbis-enc.cc gsldatacache.cc gslvorbis-cutter.cc \
+ gsldatahandle-mad.cc gslfilehash.cc gsldatautils.cc \
+ gslwaveosc.cc gslosctable.cc gslmagic.cc \
\
bseengine.c bseenginemaster.c bseengineschedule.c bseengineutils.c \
bsebus.cc bsecategories.cc \
@@ -125,7 +125,7 @@ EXTRA_DIST += $(strip \
mktypes.pl mkcalls.pl mkcproc.pl \
bseconfig.h.in bsepcmmodule.cc \
bsewave.header \
- gsl-fftgen.pl gsl-fftconf.sh gsloscillator-aux.c \
+ gsl-fftgen.pl gsl-fftconf.sh gsloscillator-aux.cc \
gslincluder.c gslwaveosc-aux.cc \
)
diff --git a/bse/gslcommon.c b/bse/gslcommon.cc
similarity index 97%
rename from bse/gslcommon.c
rename to bse/gslcommon.cc
index 745ae6c..08e2804 100644
--- a/bse/gslcommon.c
+++ b/bse/gslcommon.cc
@@ -234,7 +234,7 @@ gsl_error_select (guint n_errors,
{
BseErrorType *errors = g_new (BseErrorType, MAX (1, n_errors));
va_list args;
- guint i, e, score;
+ guint i, score;
/* function used to select a descriptive error in
* multi-error scenarios
*/
@@ -242,12 +242,12 @@ gsl_error_select (guint n_errors,
for (i = 0; i < n_errors; i++)
{
if (i)
- first_error = va_arg (args, BseErrorType);
+ first_error = (BseErrorType) va_arg (args, int); // BseErrorType
errors[i] = first_error;
}
va_end (args);
/* grab first error, unless followed by an error with higher score */
- e = errors[0];
+ BseErrorType e = errors[0];
score = score_error (e);
for (i = 1; i < n_errors; i++)
{
@@ -326,11 +326,11 @@ gsl_progress_wipe (GslProgressState *pstate)
if (pstate->wipe_length)
{
- gchar *wstr = g_malloc (pstate->wipe_length + 1 + 1);
+ char *wstr = (char*) g_malloc (pstate->wipe_length + 1 + 1);
memset (wstr, ' ', pstate->wipe_length);
wstr[pstate->wipe_length] = '\r';
wstr[pstate->wipe_length + 1] = 0;
- g_printerr (wstr);
+ g_printerr ("%s", wstr);
g_free (wstr);
pstate->wipe_length = 0;
}
diff --git a/bse/gsldatacache.c b/bse/gsldatacache.cc
similarity index 99%
rename from bse/gsldatacache.c
rename to bse/gsldatacache.cc
index df7f3ed..a672ab6 100644
--- a/bse/gsldatacache.c
+++ b/bse/gsldatacache.cc
@@ -552,7 +552,7 @@ gsl_data_cache_unref_node (GslDataCache *dcache,
if (current_mem > cache_mem) /* round-robin cache trashing */
{
guint dcache_count, needs_unlock;
- dcache = sfi_ring_pop_head (&global_dcache_list);
+ dcache = (GslDataCache*) sfi_ring_pop_head (&global_dcache_list);
GSL_SPIN_LOCK (&dcache->mutex);
dcache->ref_count++;
global_dcache_list = sfi_ring_append (global_dcache_list, dcache);
@@ -625,7 +625,7 @@ gsl_data_cache_from_dhandle (GslDataHandle *dhandle,
GSL_SPIN_LOCK (&global_dcache_mutex);
for (ring = global_dcache_list; ring; ring = sfi_ring_walk (ring, global_dcache_list))
{
- GslDataCache *dcache = ring->data;
+ GslDataCache *dcache = (GslDataCache*) ring->data;
if (dcache->dhandle == dhandle && dcache->padding >= min_padding)
{
diff --git a/bse/gsldatahandle-mad.c b/bse/gsldatahandle-mad.cc
similarity index 97%
rename from bse/gsldatahandle-mad.c
rename to bse/gsldatahandle-mad.cc
index f569ce7..5f1d4d4 100644
--- a/bse/gsldatahandle-mad.c
+++ b/bse/gsldatahandle-mad.cc
@@ -164,7 +164,7 @@ check_frame_validity (MadHandle *handle,
struct mad_header *header)
{
guint frame_size = MAD_NSBSAMPLES (header) * 32;
- gchar *reason = NULL;
+ const char *reason = NULL;
if (frame_size <= 0)
reason = "frame_size < 1";
@@ -202,7 +202,7 @@ read_next_frame_header (MadHandle *handle)
/* read on */
if (!stream_read (handle))
{
- handle->error = handle->eof ? 0 : gsl_error_from_errno (errno, BSE_ERROR_FILE_EOF);
+ handle->error = handle->eof ? BSE_ERROR_NONE : gsl_error_from_errno (errno, BSE_ERROR_FILE_EOF);
return FALSE;
}
return read_next_frame_header (handle); /* retry */
@@ -214,7 +214,7 @@ read_next_frame_header (MadHandle *handle)
succeeded = FALSE;
}
- handle->error = handle->stream.error ? error_from_mad_stream (&handle->stream, BSE_ERROR_FILE_SEEK_FAILED) : 0;
+ handle->error = handle->stream.error ? error_from_mad_stream (&handle->stream, BSE_ERROR_FILE_SEEK_FAILED) : BSE_ERROR_NONE;
return succeeded;
}
@@ -238,7 +238,7 @@ pcm_frame_read (MadHandle *handle,
/* read on */
if (!stream_read (handle))
{
- handle->error = handle->eof ? 0 : gsl_error_from_errno (errno, BSE_ERROR_FILE_READ_FAILED);
+ handle->error = handle->eof ? BSE_ERROR_NONE : gsl_error_from_errno (errno, BSE_ERROR_FILE_READ_FAILED);
return FALSE;
}
return pcm_frame_read (handle, synth); /* retry */
@@ -259,7 +259,7 @@ pcm_frame_read (MadHandle *handle,
if (!succeeded && handle->stream.error)
handle->error = error_from_mad_stream (&handle->stream, BSE_ERROR_FILE_READ_FAILED);
else
- handle->error = 0;
+ handle->error = BSE_ERROR_NONE;
return succeeded;
}
@@ -267,8 +267,7 @@ static guint*
create_seek_table (MadHandle *handle,
guint *n_seeks_p)
{
- guint *seeks = NULL;
- guint offs, n_seeks = 0;
+ uint *seeks = NULL, n_seeks = 0;
*n_seeks_p = 0;
mad_synth_finish (&handle->synth);
@@ -279,7 +278,6 @@ create_seek_table (MadHandle *handle,
mad_synth_init (&handle->synth);
mad_stream_options (&handle->stream, handle->stream_options);
- offs = 0;
/* lseek (handle->hfile, offs, SEEK_SET) */
handle->eof = FALSE;
handle->bfill = 0;
@@ -334,7 +332,6 @@ create_seek_table (MadHandle *handle,
while (!handle->eof);
/* reset file offset */
- offs = 0;
/* lseek (handle->hfile, offs, SEEK_SET) */
handle->eof = FALSE;
handle->file_pos = 0;
@@ -697,7 +694,7 @@ dh_mad_new (const gchar *file_name,
handle->eof = FALSE;
handle->hfile = NULL;
handle->file_pos = 0;
- handle->error = 0;
+ handle->error = BSE_ERROR_NONE;
handle->n_seeks = 0;
handle->seeks = NULL;
handle->seek_mtime = -1;
@@ -712,7 +709,7 @@ dh_mad_new (const gchar *file_name,
{
if (!skip_seek_keep_open)
gsl_data_handle_close (&handle->dhandle);
- *errorp = 0;
+ *errorp = BSE_ERROR_NONE;
return &handle->dhandle;
}
MAD_DEBUG ("failed to open \"%s\": %s", file_name, handle->stream.error ? mad_stream_errorstr (&handle->stream) : bse_error_blurb (error));
@@ -737,7 +734,7 @@ gsl_data_handle_new_mad_err (const gchar *file_name,
g_return_val_if_fail (file_name != NULL, NULL);
g_return_val_if_fail (osc_freq > 0, NULL);
- BseErrorType error = 0;
+ BseErrorType error = BSE_ERROR_NONE;
return dh_mad_new (file_name, osc_freq, FALSE, errorp ? errorp : &error);
}
@@ -751,7 +748,7 @@ gsl_data_handle_mad_testopen (const gchar *file_name,
g_return_val_if_fail (file_name != NULL, BSE_ERROR_INTERNAL);
- BseErrorType error = 0;
+ BseErrorType error = BSE_ERROR_NONE;
dhandle = dh_mad_new (file_name, 439, TRUE, &error);
if (!dhandle)
return error ? error : BSE_ERROR_FILE_OPEN_FAILED;
diff --git a/bse/gsldatahandle-vorbis.c b/bse/gsldatahandle-vorbis.cc
similarity index 97%
rename from bse/gsldatahandle-vorbis.c
rename to bse/gsldatahandle-vorbis.cc
index dd07024..8695db1 100644
--- a/bse/gsldatahandle-vorbis.c
+++ b/bse/gsldatahandle-vorbis.cc
@@ -92,7 +92,7 @@ vfile_read (void *ptr,
size_t nmemb,
void *datasource)
{
- VFile *vfile = datasource;
+ VFile *vfile = (VFile*) datasource;
size_t bytes = size * nmemb;
size_t bytes_to_eof = vfile->byte_length - (gsl_rfile_position (vfile->rfile) - vfile->byte_offset);
return gsl_rfile_read (vfile->rfile, MIN (bytes, bytes_to_eof), ptr);
@@ -103,7 +103,7 @@ vfile_seek (void *datasource,
ogg_int64_t offset,
int whence)
{
- VFile *vfile = datasource;
+ VFile *vfile = (VFile*) datasource;
ogg_int64_t l;
switch (whence)
{
@@ -130,7 +130,7 @@ vfile_seek (void *datasource,
static int
vfile_close (void *datasource)
{
- VFile *vfile = datasource;
+ VFile *vfile = (VFile*) datasource;
gsl_rfile_close (vfile->rfile);
g_free (vfile);
return 0;
@@ -139,7 +139,7 @@ vfile_close (void *datasource)
static long
vfile_tell (void *datasource)
{
- VFile *vfile = datasource;
+ VFile *vfile = (VFile*) datasource;
return gsl_rfile_position (vfile->rfile) - vfile->byte_offset;
}
@@ -273,17 +273,17 @@ static void
read_packet (VorbisHandle *vhandle)
{
gfloat **pcm = NULL;
- gint stream_id, i;
-
+ gint stream_id;
+
vhandle->pcm_pos = ov_pcm_tell (&vhandle->ofile) - vhandle->soffset;
vhandle->pcm_length = ov_read_float (&vhandle->ofile, &pcm, G_MAXINT, &stream_id);
- if (vhandle->pcm_pos < 0 || vhandle->pcm_length < 0 || stream_id != vhandle->bitstream)
+ if (vhandle->pcm_pos < 0 || vhandle->pcm_length < 0 || stream_id != int (vhandle->bitstream))
{
/* urg, this is bad! */
dh_vorbis_coarse_seek (&vhandle->dhandle, 0);
}
else
- for (i = 0; i < vhandle->dhandle.setup.n_channels; i++)
+ for (uint i = 0; i < vhandle->dhandle.setup.n_channels; i++)
vhandle->pcm[i] = pcm[i];
}
@@ -569,6 +569,6 @@ gsl_vorbis1_handle_put_wstore (GslVorbis1Handle *vorbis1,
guint
gsl_vorbis_make_serialno (void)
{
- static guint global_ogg_serial = ('B' << 24) | ('S' << 16) | ('E' << 8) | 128;
- return g_atomic_int_exchange_and_add (&global_ogg_serial, 1);
+ static volatile uint global_ogg_serial = ('B' << 24) | ('S' << 16) | ('E' << 8) | 128;
+ return __sync_fetch_and_add (&global_ogg_serial, 1);
}
diff --git a/bse/gsldatahandle.c b/bse/gsldatahandle.cc
similarity index 98%
rename from bse/gsldatahandle.c
rename to bse/gsldatahandle.cc
index 329f394..dcf79c0 100644
--- a/bse/gsldatahandle.c
+++ b/bse/gsldatahandle.cc
@@ -514,8 +514,8 @@ xinfo_handle_open (GslDataHandle *dhandle,
i = 0;
while (sxinfos)
{
- const gchar *xinfo = sfi_ring_pop_head (&sxinfos);
- const gchar *e = strchr (xinfo, '=');
+ const char *xinfo = (const char*) sfi_ring_pop_head (&sxinfos);
+ const char *e = strchr (xinfo, '=');
if (e[1]) /* non-empty xinfo */
setup->xinfos[i++] = g_strdup (xinfo);
}
@@ -622,8 +622,8 @@ xinfo_data_handle_new (GslDataHandle *src_handle,
SfiRing *ring = NULL;
while (dest_added)
{
- gchar *xinfo = sfi_ring_pop_head (&dest_added);
- const gchar *e = strchr (xinfo, '=');
+ char *xinfo = (char*) sfi_ring_pop_head (&dest_added);
+ const char *e = strchr (xinfo, '=');
if (e[1]) /* non-empty xinfo */
ring = sfi_ring_append (ring, xinfo);
else
@@ -644,8 +644,8 @@ xinfo_data_handle_new (GslDataHandle *src_handle,
ring = NULL;
while (dest_remove)
{
- gchar *xinfo = sfi_ring_pop_head (&dest_remove);
- const gchar *e = strchr (xinfo, '=');
+ char *xinfo = (char*) sfi_ring_pop_head (&dest_remove);
+ const char *e = strchr (xinfo, '=');
if (!e[1]) /* empty xinfo */
ring = sfi_ring_append (ring, xinfo);
else
@@ -1398,7 +1398,7 @@ dcache_handle_read (GslDataHandle *dhandle,
DCacheHandle *chandle = (DCacheHandle*) dhandle;
GslDataCacheNode *node;
- node = gsl_data_cache_ref_node (chandle->dcache, voffset, TRUE);
+ node = gsl_data_cache_ref_node (chandle->dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
voffset -= node->offset;
n_values = MIN (n_values, chandle->node_size - voffset);
memcpy (values, node->data + voffset, sizeof (values[0]) * n_values);
@@ -1604,7 +1604,7 @@ wave_handle_read (GslDataHandle *dhandle,
{
guint8 *u8; gint8 *s8; guint16 *u16; guint32 *u32; gint32 *s32;
case GSL_WAVE_FORMAT_UNSIGNED_8:
- u8 = buffer; u8 += n_values * 3;
+ u8 = (guint8*) buffer; u8 += n_values * 3;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values, u8);
if (l < 1)
return l;
@@ -1613,7 +1613,7 @@ wave_handle_read (GslDataHandle *dhandle,
case GSL_WAVE_FORMAT_SIGNED_8:
case GSL_WAVE_FORMAT_ALAW:
case GSL_WAVE_FORMAT_ULAW:
- s8 = buffer; s8 += n_values * 3;
+ s8 = (gint8*) buffer; s8 += n_values * 3;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values, s8);
if (l < 1)
return l;
@@ -1623,7 +1623,7 @@ wave_handle_read (GslDataHandle *dhandle,
case GSL_WAVE_FORMAT_UNSIGNED_12:
case GSL_WAVE_FORMAT_SIGNED_16:
case GSL_WAVE_FORMAT_UNSIGNED_16:
- u16 = buffer; u16 += n_values;
+ u16 = (guint16*) buffer; u16 += n_values;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values << 1, u16);
if (l < 2)
return l < 0 ? l : 0;
@@ -1631,7 +1631,7 @@ wave_handle_read (GslDataHandle *dhandle,
gsl_conv_to_float (whandle->format, whandle->byte_order, u16, values, l);
break;
case GSL_WAVE_FORMAT_SIGNED_24:
- s8 = buffer; s8 += n_values * 1;
+ s8 = (gint8*) buffer; s8 += n_values * 1;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values * 3, s8);
if (l < 3)
return l < 0 ? l : 0;
@@ -1639,7 +1639,7 @@ wave_handle_read (GslDataHandle *dhandle,
gsl_conv_to_float (whandle->format, whandle->byte_order, s8, values, l);
break;
case GSL_WAVE_FORMAT_SIGNED_24_PAD4:
- s32 = buffer;
+ s32 = (gint32*) buffer;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values * 4, s32);
if (l < 4)
return l < 0 ? l : 0;
@@ -1647,7 +1647,7 @@ wave_handle_read (GslDataHandle *dhandle,
gsl_conv_to_float (whandle->format, whandle->byte_order, s32, values, l);
break;
case GSL_WAVE_FORMAT_SIGNED_32:
- s32 = buffer;
+ s32 = (gint32*) buffer;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values * 4, s32);
if (l < 4)
return l < 0 ? l : 0;
@@ -1655,7 +1655,7 @@ wave_handle_read (GslDataHandle *dhandle,
gsl_conv_to_float (whandle->format, whandle->byte_order, s32, values, l);
break;
case GSL_WAVE_FORMAT_FLOAT:
- u32 = buffer;
+ u32 = (guint32*) buffer;
l = gsl_hfile_pread (whandle->hfile, byte_offset, n_values << 2, u32);
if (l < 4)
return l < 0 ? l : 0;
diff --git a/bse/gsldatautils.c b/bse/gsldatautils.cc
similarity index 98%
rename from bse/gsldatautils.c
rename to bse/gsldatautils.cc
index d242137..f2b4131 100644
--- a/bse/gsldatautils.c
+++ b/bse/gsldatautils.cc
@@ -275,7 +275,7 @@ bse_wave_file_from_fbuffer (const char *file_name,
void *buffer = g_new (guint32, n_values);
GslLong n = gsl_conv_from_float_clip (n_bits > 8 ? GSL_WAVE_FORMAT_SIGNED_16 : GSL_WAVE_FORMAT_UNSIGNED_8,
G_LITTLE_ENDIAN, values, buffer, n_values);
- int retval = bse_wave_file_from_bbuffer (file_name, n_bits, n_channels, sample_freq, n_values, n, buffer);
+ int retval = bse_wave_file_from_bbuffer (file_name, n_bits, n_channels, sample_freq, n_values, n, (const uint8*) buffer);
g_free (buffer);
return retval;
}
@@ -292,7 +292,7 @@ bse_wave_file_from_dbuffer (const char *file_name,
void *buffer = g_new (guint32, n_values);
GslLong n = gsl_conv_from_double_clip (n_bits > 8 ? GSL_WAVE_FORMAT_SIGNED_16 : GSL_WAVE_FORMAT_UNSIGNED_8,
G_LITTLE_ENDIAN, values, buffer, n_values);
- int retval = bse_wave_file_from_bbuffer (file_name, n_bits, n_channels, sample_freq, n_values, n, buffer);
+ int retval = bse_wave_file_from_bbuffer (file_name, n_bits, n_channels, sample_freq, n_values, n, (const uint8*) buffer);
g_free (buffer);
return retval;
}
@@ -335,7 +335,7 @@ typedef struct {
static void
wstore_context_destroy (gpointer data)
{
- WStoreContext *wc = data;
+ WStoreContext *wc = (WStoreContext*) data;
if (wc->opened)
gsl_data_handle_close (wc->dhandle);
gsl_data_handle_unref (wc->dhandle);
@@ -347,7 +347,7 @@ wstore_context_reader (gpointer data,
void *buffer,
guint blength)
{
- WStoreContext *wc = data;
+ WStoreContext *wc = (WStoreContext*) data;
GslLong l;
if (!wc->opened)
@@ -362,17 +362,17 @@ wstore_context_reader (gpointer data,
if (wc->length >= gsl_data_handle_length (wc->dhandle))
return 0; /* done */
- l = gsl_data_handle_read (wc->dhandle, wc->length, blength, buffer);
+ l = gsl_data_handle_read (wc->dhandle, wc->length, blength, (float*) buffer);
if (l < 1)
{
/* single retry */
- l = gsl_data_handle_read (wc->dhandle, wc->length, blength, buffer);
+ l = gsl_data_handle_read (wc->dhandle, wc->length, blength, (float*) buffer);
if (l < 1)
return -EIO; /* bail out */
}
wc->length += l;
- return gsl_conv_from_float_clip (wc->format, wc->byte_order, buffer, buffer, l);
+ return gsl_conv_from_float_clip (wc->format, wc->byte_order, (const float*) buffer, buffer, l);
}
void
@@ -467,7 +467,7 @@ gsl_data_find_min_max (GslDataHandle *handle,
gsl_data_handle_open (handle);
GslDataPeekBuffer peek_buffer = { +1 /* incremental direction */, 0, };
- double vmin = +1e999, vmax = -1e999;
+ double vmin = +DBL_MAX, vmax = -DBL_MAX;
uint i;
for (i = 0; i < handle->setup.n_values; i++)
{
diff --git a/bse/gslfilehash.c b/bse/gslfilehash.cc
similarity index 97%
rename from bse/gslfilehash.c
rename to bse/gslfilehash.cc
index 5551436..b5a618b 100644
--- a/bse/gslfilehash.c
+++ b/bse/gslfilehash.cc
@@ -26,7 +26,7 @@
/* macros */
#if (GLIB_SIZEOF_LONG > 4)
-#define HASH_LONG(l) (l + (l >> 32))
+#define HASH_LONG(l) (l + (guint64 (l) >> 32))
#else
#define HASH_LONG(l) (l)
#endif
@@ -41,7 +41,7 @@ static GHashTable *hfile_ht = NULL;
static guint
hfile_hash (gconstpointer key)
{
- const GslHFile *hfile = key;
+ const GslHFile *hfile = (const GslHFile*) key;
guint h;
h = HASH_LONG (hfile->mtime);
@@ -55,8 +55,8 @@ static gboolean
hfile_equals (gconstpointer key1,
gconstpointer key2)
{
- const GslHFile *hfile1 = key1;
- const GslHFile *hfile2 = key2;
+ const GslHFile *hfile1 = (const GslHFile*) key1;
+ const GslHFile *hfile2 = (const GslHFile*) key2;
return (hfile1->mtime == hfile2->mtime &&
hfile1->n_bytes == hfile2->n_bytes &&
@@ -114,7 +114,7 @@ gsl_hfile_open (const gchar *file_name)
return NULL; /* errno from stat() */
sfi_mutex_lock (&fdpool_mutex);
- hfile = g_hash_table_lookup (hfile_ht, &key);
+ hfile = (GslHFile*) g_hash_table_lookup (hfile_ht, &key);
if (hfile)
{
sfi_mutex_lock (&hfile->mutex);
@@ -316,7 +316,7 @@ gsl_hfile_zoffset (GslHFile *hfile)
return -1;
}
- p = memchr (sdata, 0, l);
+ p = (guint8*) memchr (sdata, 0, l);
seen_zero = p != NULL;
zoffset += seen_zero ? p - sdata : l;
}
diff --git a/bse/gslfilter.c b/bse/gslfilter.cc
similarity index 100%
rename from bse/gslfilter.c
rename to bse/gslfilter.cc
diff --git a/bse/gslmagic.c b/bse/gslmagic.cc
similarity index 93%
rename from bse/gslmagic.c
rename to bse/gslmagic.cc
index e8e659d..67f24bf 100644
--- a/bse/gslmagic.c
+++ b/bse/gslmagic.cc
@@ -33,7 +33,6 @@
/* --- typedefs & structures --- */
-typedef struct _Magic Magic;
typedef struct _BFile BFile;
struct _BFile
{
@@ -47,10 +46,8 @@ struct _BFile
/* --- prototypes --- */
-static Magic* magic_create (gchar *magic_string,
- const gchar *original);
-static gboolean magic_match_file (BFile *bfile,
- Magic *magics);
+static GslRealMagic* magic_create (char *magic_string, const char *original);
+static gboolean magic_match_file (BFile *bfile, GslRealMagic *magics);
static gboolean bfile_open (BFile *bfile,
const gchar *file_name,
guint skip_offset);
@@ -68,8 +65,8 @@ magic_cmp (gconstpointer p1,
gconstpointer p2,
gpointer data)
{
- const GslMagic *m1 = p1;
- const GslMagic *m2 = p2;
+ const GslMagic *m1 = (const GslMagic*) p1;
+ const GslMagic *m2 = (const GslMagic*) p2;
/* smaller values are higher priority */
return m2->priority - m1->priority;
}
@@ -95,15 +92,15 @@ gsl_magic_list_brute_match (SfiRing *magic_list,
if (bfile_open (&bfile, file_name, skip_bytes))
{
- gchar *extension = strrchr (file_name, '.');
+ const char *extension = strrchr (file_name, '.');
SfiRing *node;
/* match by extension */
if (ext_matches && extension)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
- GslMagic *magic = node->data;
-
+ GslMagic *magic = (GslMagic*) node->data;
+
if (!magic->extension || strcmp (magic->extension, extension) != 0)
continue;
if (magic != skip_magic && magic_match_file (&bfile, magic->match_list))
@@ -113,8 +110,8 @@ gsl_magic_list_brute_match (SfiRing *magic_list,
if (other_matches)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
- GslMagic *magic = node->data;
-
+ GslMagic *magic = (GslMagic*) node->data;
+
if (extension && magic->extension && strcmp (magic->extension, extension) == 0)
continue;
if (magic != skip_magic && magic_match_file (&bfile, magic->match_list))
@@ -140,16 +137,16 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
if (bfile_open (&bfile, file_name, skip_offset))
{
- gchar *extension = strrchr (file_name, '.');
+ const char *extension = strrchr (file_name, '.');
gint rpriority = G_MAXINT;
SfiRing *node;
-
+
/* we do a quick scan by extension first */
if (!rmagic && extension)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
- GslMagic *magic = node->data;
-
+ GslMagic *magic = (GslMagic*) node->data;
+
if (!magic->extension
|| strcmp (magic->extension, extension) != 0
|| rpriority < magic->priority
@@ -165,8 +162,8 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
if (!rmagic && extension)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
- GslMagic *magic = node->data;
-
+ GslMagic *magic = (GslMagic*) node->data;
+
if ((magic->extension && strcmp (magic->extension, extension) == 0)
|| rpriority < magic->priority
|| (rmagic && rpriority == magic->priority))
@@ -181,8 +178,8 @@ gsl_magic_list_match_file_skip (SfiRing *magic_list,
if (!rmagic && !extension)
for (node = magic_list; node; node = sfi_ring_walk (node, magic_list))
{
- GslMagic *magic = node->data;
-
+ GslMagic *magic = (GslMagic*) node->data;
+
if (rpriority < magic->priority ||
(rmagic && rpriority == magic->priority))
continue;
@@ -212,7 +209,7 @@ gsl_magic_create (gpointer data,
const gchar *magic_spec)
{
GslMagic *magic;
- Magic *match_list;
+ GslRealMagic *match_list;
gchar *magic_string;
g_return_val_if_fail (magic_spec != NULL, NULL);
@@ -233,7 +230,7 @@ gsl_magic_create (gpointer data,
}
-/* --- Magic creation/checking --- */
+/* --- GslRealMagic creation/checking --- */
typedef enum
{
MAGIC_CHECK_ANY,
@@ -254,9 +251,9 @@ typedef union
guint32 v_uint32;
gchar *v_string;
} MagicData;
-struct _Magic
+struct _GslRealMagic
{
- Magic *next;
+ GslRealMagic *next;
gulong offset;
guint data_size;
MagicCheckType magic_check;
@@ -271,8 +268,7 @@ static const gchar *magic_field_delims = " \t,";
static const gchar *magic_string_delims = " \t\n\r";
static gboolean
-magic_parse_test (Magic *magic,
- const gchar *string)
+magic_parse_test (GslRealMagic *magic, const gchar *string)
{
if (!magic->read_string)
{
@@ -369,8 +365,7 @@ magic_parse_test (Magic *magic,
}
static gboolean
-magic_parse_type (Magic *magic,
- const gchar *string)
+magic_parse_type (GslRealMagic *magic, const gchar *string)
{
gchar *f = NULL;
@@ -452,8 +447,7 @@ magic_parse_type (Magic *magic,
}
static gboolean
-magic_parse_offset (Magic *magic,
- gchar *string)
+magic_parse_offset (GslRealMagic *magic, char *string)
{
gchar *f = NULL;
@@ -465,13 +459,12 @@ magic_parse_offset (Magic *magic,
return !f || *f == 0;
}
-static Magic*
-magic_create (gchar *magic_string,
- const gchar *original)
+static GslRealMagic*
+magic_create (char *magic_string, const char *original)
{
#define SKIP_CLEAN(s) { while (*s && !strchr (magic_field_delims, *s)) s++; \
if (*s) do *(s++) = 0; while (strchr (magic_field_delims, *s)); }
- Magic *magics = NULL;
+ GslRealMagic *magics = NULL;
gchar *p = magic_string;
while (p && *p)
@@ -486,11 +479,10 @@ magic_create (gchar *magic_string,
}
else
{
- Magic *tmp = magics;
-
- magics = g_new0 (Magic, 1);
+ GslRealMagic *tmp = magics;
+ magics = g_new0 (GslRealMagic, 1);
magics->next = tmp;
-
+
magic_string = p;
SKIP_CLEAN (p);
if (!magic_parse_offset (magics, magic_string))
@@ -524,8 +516,7 @@ magic_create (gchar *magic_string,
}
static gboolean
-magic_check_data (Magic *magic,
- MagicData *data)
+magic_check_data (GslRealMagic *magic, MagicData *data)
{
gint cmp = 0;
@@ -581,9 +572,7 @@ magic_check_data (Magic *magic,
}
static inline gboolean
-magic_read_data (BFile *bfile,
- Magic *magic,
- MagicData *data)
+magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
{
guint file_size = bfile_get_size (bfile);
@@ -644,8 +633,7 @@ magic_read_data (BFile *bfile,
}
static gboolean
-magic_match_file (BFile *bfile,
- Magic *magics)
+magic_match_file (BFile *bfile, GslRealMagic *magics)
{
g_return_val_if_fail (bfile != NULL, FALSE);
g_return_val_if_fail (magics != NULL, FALSE);
@@ -654,12 +642,12 @@ magic_match_file (BFile *bfile,
{
gchar data_string[MAX_MAGIC_STRING + 1];
MagicData data;
-
+
if (magics->read_string)
data.v_string = data_string;
else
data.v_uint32 = 0;
-
+
if (!magic_read_data (bfile, magics, &data) ||
!magic_check_data (magics, &data))
return FALSE;
@@ -707,7 +695,7 @@ bfile_open (BFile *bfile,
do
ret = lseek (bfile->fd, skip_offset, SEEK_SET);
while (ret < 0 && errno == EINTR);
- if (ret != skip_offset)
+ if (ret < 0 || uint (ret) != skip_offset)
{
bfile_close (bfile);
return FALSE;
diff --git a/bse/gslmagic.h b/bse/gslmagic.h
index f3ae18b..718c5d5 100644
--- a/bse/gslmagic.h
+++ b/bse/gslmagic.h
@@ -27,14 +27,15 @@ extern "C" {
/* --- structures --- */
+typedef struct _GslRealMagic GslRealMagic;
struct _GslMagic
{
gpointer data;
gchar *extension;
/*< private >*/
- gint priority;
- gpointer match_list;
+ gint priority;
+ GslRealMagic *match_list;
};
diff --git a/bse/gsloscillator-aux.c b/bse/gsloscillator-aux.cc
similarity index 100%
rename from bse/gsloscillator-aux.c
rename to bse/gsloscillator-aux.cc
diff --git a/bse/gsloscillator.c b/bse/gsloscillator.cc
similarity index 98%
rename from bse/gsloscillator.c
rename to bse/gsloscillator.cc
index 5dadeca..87fdcd8 100644
--- a/bse/gsloscillator.c
+++ b/bse/gsloscillator.cc
@@ -86,7 +86,7 @@ osc_update_pwm_offset (GslOscData *osc,
#define GSL_INCLUDER_TABLE static void (*osc_process_table[]) (GslOscData*,guint, \
const gfloat*,const gfloat*,const gfloat*, \
const gfloat*,gfloat*,gfloat*)
-#define GSL_INCLUDER_FILE "gsloscillator-aux.c"
+#define GSL_INCLUDER_FILE "gsloscillator-aux.cc"
#include "gslincluder.c"
#undef OSC_INCLUDER_FLAGS
@@ -98,7 +98,7 @@ osc_update_pwm_offset (GslOscData *osc,
#define GSL_INCLUDER_TABLE static void (*osc_process_pulse_table[]) (GslOscData*,guint, \
const gfloat*,const gfloat*,const gfloat*, \
const gfloat*,gfloat*,gfloat*)
-#define GSL_INCLUDER_FILE "gsloscillator-aux.c"
+#define GSL_INCLUDER_FILE "gsloscillator-aux.cc"
#include "gslincluder.c"
#undef OSC_INCLUDER_FLAGS
diff --git a/bse/gslosctable.c b/bse/gslosctable.cc
similarity index 89%
rename from bse/gslosctable.c
rename to bse/gslosctable.cc
index b75866e..a6b47ac 100644
--- a/bse/gslosctable.c
+++ b/bse/gslosctable.cc
@@ -19,7 +19,6 @@
#include "bsemath.h"
#include "gslfft.h"
#include <string.h>
-#include <sfi/gbsearcharray.h>
static SFI_MSG_TYPE_DEFINE (debug_osc, "osc", SFI_MSG_DEBUG, NULL);
@@ -35,7 +34,7 @@ static SFI_MSG_TYPE_DEFINE (debug_osc, "osc", SFI_MSG_DEBUG, NULL);
/* --- structures --- */
-typedef struct
+struct OscTableEntry
{
/* main key (osc and cache tables) */
gfloat mfreq; /* [0..0.5], mix_freq relative */
@@ -46,8 +45,8 @@ typedef struct
guint ref_count;
guint min_pos, max_pos; /* pulse extension */
guint n_values;
- const gfloat values[1]; /* flexible array */
-} OscTableEntry;
+ float values[1]; /* flexible array */
+};
/* --- prototypes --- */
@@ -81,8 +80,8 @@ static gint
cache_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2)
{
- const OscTableEntry * const *ep1 = bsearch_node1;
- const OscTableEntry * const *ep2 = bsearch_node2;
+ const OscTableEntry *const *ep1 = (const OscTableEntry*const*) bsearch_node1;
+ const OscTableEntry *const *ep2 = (const OscTableEntry*const*) bsearch_node2;
const OscTableEntry *e1 = *ep1;
const OscTableEntry *e2 = *ep2;
@@ -101,8 +100,8 @@ static gint
osc_table_entry_locs_cmp (gconstpointer bsearch_node1, /* key */
gconstpointer bsearch_node2)
{
- const OscTableEntry * const *ep1 = bsearch_node1;
- const OscTableEntry * const *ep2 = bsearch_node2;
+ const OscTableEntry *const *ep1 = (const OscTableEntry*const*) bsearch_node1;
+ const OscTableEntry *const *ep2 = (const OscTableEntry*const*) bsearch_node2;
const OscTableEntry *e1 = *ep1;
const OscTableEntry *e2 = *ep2;
@@ -115,23 +114,23 @@ cache_table_entry_lookup_best (GslOscWaveForm wave_form,
gfloat mfreq)
{
OscTableEntry key, *k = &key, **ep1 = NULL, **ep2, **ep3 = NULL;
-
+
key.mfreq = mfreq;
key.wave_form = wave_form;
key.filter_func = filter_func;
-
+
/* get exact match or a match which is one off into either direction */
- ep2 = g_bsearch_array_lookup_sibling (cache_entries, &cache_taconfig, &k);
+ ep2 = (OscTableEntry**) g_bsearch_array_lookup_sibling (cache_entries, &cache_taconfig, &k);
if (ep2)
{
- guint i = g_bsearch_array_get_index (cache_entries, &cache_taconfig, ep2);
-
+ uint i = g_bsearch_array_get_index (cache_entries, &cache_taconfig, ep2);
+
/* get siblings */
if (i > 0)
- ep1 = g_bsearch_array_get_nth (cache_entries, &cache_taconfig, i - 1);
+ ep1 = (OscTableEntry**) g_bsearch_array_get_nth (cache_entries, &cache_taconfig, i - 1);
if (i + 1 < g_bsearch_array_get_n_nodes (cache_entries))
- ep3 = g_bsearch_array_get_nth (cache_entries, &cache_taconfig, i + 1);
-
+ ep3 = (OscTableEntry**) g_bsearch_array_get_nth (cache_entries, &cache_taconfig, i + 1);
+
/* get rid of invalid matches, i.e. ones with:
* - a different wave
* - a different filter
@@ -182,20 +181,20 @@ osc_table_entry_lookup_best (const GslOscTable *table,
gfloat *min_mfreq)
{
OscTableEntry key, *k = &key, **ep;
- guint i;
-
+ uint i;
+
/* get exact match or a match which is one off into either direction */
key.mfreq = mfreq;
- ep = g_bsearch_array_lookup_sibling (table->entry_array, &osc_taconfig, &k);
+ ep = (OscTableEntry**) g_bsearch_array_lookup_sibling (table->entry_array, &osc_taconfig, &k);
if (UNLIKELY (!ep))
return NULL; /* ugh, bad */
-
+
if (mfreq > (*ep)->mfreq) /* need better filter */
{
i = g_bsearch_array_get_index (table->entry_array, &osc_taconfig, ep);
if (i + 1 < g_bsearch_array_get_n_nodes (table->entry_array))
{
- ep = g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, i + 1);
+ ep = (OscTableEntry**) g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, i + 1);
OSC_DEBUG ("osc-lookup: want_freq=%f got_freq=%f (table=%p, i=%u, n=%u)",
mfreq * table->mix_freq, (*ep)->mfreq * table->mix_freq,
table, i + 1, g_bsearch_array_get_n_nodes (table->entry_array));
@@ -217,7 +216,7 @@ osc_table_entry_lookup_best (const GslOscTable *table,
i = g_bsearch_array_get_index (table->entry_array, &osc_taconfig, ep);
if (i > 0)
{
- OscTableEntry **tp = g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, i - 1);
+ OscTableEntry **tp = (OscTableEntry**) g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, i - 1);
*min_mfreq = (*tp)->mfreq;
}
@@ -284,7 +283,7 @@ cache_table_ref_entry (GslOscWaveForm wave_form,
* - OscTableEntry already contains the first float values
* - we need n_values+1 adressable floats to provide values[0] == values[n_values]
*/
- e = g_malloc (sizeof (OscTableEntry) + sizeof (gfloat) * size);
+ e = (OscTableEntry*) g_malloc (sizeof (OscTableEntry) + sizeof (gfloat) * size);
values = (gfloat*) &e->values[0];
e->wave_form = wave_form;
e->filter_func = (guint8*) filter_func;
@@ -325,11 +324,8 @@ cache_table_unref_entry (OscTableEntry *e)
e->ref_count -= 1;
if (e->ref_count == 0)
{
- OscTableEntry **ep;
- guint i;
-
- ep = g_bsearch_array_lookup (cache_entries, &cache_taconfig, &e);
- i = g_bsearch_array_get_index (cache_entries, &cache_taconfig, ep);
+ OscTableEntry **ep = (OscTableEntry**) g_bsearch_array_lookup (cache_entries, &cache_taconfig, &e);
+ uint i = g_bsearch_array_get_index (cache_entries, &cache_taconfig, ep);
cache_entries = g_bsearch_array_remove (cache_entries, &cache_taconfig, i);
}
}
@@ -431,9 +427,7 @@ gsl_osc_table_free (GslOscTable *table)
n = g_bsearch_array_get_n_nodes (table->entry_array);
while (n--)
{
- OscTableEntry **ep;
-
- ep = g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, n);
+ OscTableEntry **ep = (OscTableEntry**) g_bsearch_array_get_nth (table->entry_array, &osc_taconfig, n);
cache_table_unref_entry (*ep);
table->entry_array = g_bsearch_array_remove (table->entry_array, &osc_taconfig, n);
}
@@ -452,16 +446,17 @@ gsl_osc_wave_fill_buffer (GslOscWaveForm type,
guint n_values,
gfloat *values)
{
- gdouble max = n_values, hmax = max * 0.5, qmax = n_values * 0.25;
- gint i, half = n_values / 2, quarter = half / 2;
-
+ const double max = n_values, hmax = max * 0.5, qmax = n_values * 0.25;
+ const uint half = n_values / 2, quarter = half / 2;
+
switch (type)
{
- gdouble frac, pos;
+ double frac, pos;
+ uint i;
case GSL_OSC_WAVE_SINE:
for (i = 0; i < n_values; i++)
{
- frac = ((gdouble) i) / max; /* [0..1[ */
+ frac = (double (i)) / max; /* [0..1[ */
pos = frac * 2. * PI;
values[i] = sin (pos);
}
@@ -469,21 +464,21 @@ gsl_osc_wave_fill_buffer (GslOscWaveForm type,
case GSL_OSC_WAVE_SAW_RISE:
for (i = 0; i < n_values; i++)
{
- frac = ((gdouble) i) / max; /* [0..1[ */
+ frac = (double (i)) / max; /* [0..1[ */
values[i] = 2.0 * frac - 1.0;
}
break;
case GSL_OSC_WAVE_SAW_FALL:
for (i = 0; i < n_values; i++)
{
- frac = ((gdouble) i) / max; /* [0..1[ */
+ frac = (double (i)) / max; /* [0..1[ */
values[i] = 1.0 - 2.0 * frac;
}
break;
case GSL_OSC_WAVE_PEAK_RISE: /* spaced saw */
for (i = 0; i < half; i++)
{
- frac = ((gdouble) i) / hmax;
+ frac = (double (i)) / hmax;
values[i] = 2.0 * frac - 1.0;
}
for (; i < n_values; i++)
@@ -492,7 +487,7 @@ gsl_osc_wave_fill_buffer (GslOscWaveForm type,
case GSL_OSC_WAVE_PEAK_FALL: /* spaced saw */
for (i = 0; i < half; i++)
{
- frac = ((gdouble) i) / hmax;
+ frac = (double (i)) / hmax;
values[i] = 1.0 - 2.0 * frac;
}
for (; i < n_values; i++)
@@ -501,29 +496,29 @@ gsl_osc_wave_fill_buffer (GslOscWaveForm type,
case GSL_OSC_WAVE_TRIANGLE:
for (i = 0; i < quarter; i++)
{
- frac = ((gdouble) i) / qmax;
+ frac = (double (i)) / qmax;
values[i] = frac;
}
for (; i < half + quarter; i++)
{
- frac = ((gdouble) i - quarter) / hmax;
+ frac = (double (i) - quarter) / hmax;
values[i] = 1.0 - 2.0 * frac;
}
for (; i < n_values; i++)
{
- frac = ((gdouble) i - half - quarter) / qmax;
+ frac = (double (i) - half - quarter) / qmax;
values[i] = frac - 1.0;
}
break;
case GSL_OSC_WAVE_MOOG_SAW:
for (i = 0; i < half; i++)
{
- frac = ((gdouble) i) / hmax;
+ frac = (double (i)) / hmax;
values[i] = 2.0 * frac - 1.0;
}
for (; i < n_values; i++)
{
- frac = ((gdouble) i) / max;
+ frac = (double (i)) / max;
values[i] = 1.0 - 2.0 * frac;
}
break;
diff --git a/bse/gslosctable.h b/bse/gslosctable.h
index d7f9c94..ba50905 100644
--- a/bse/gslosctable.h
+++ b/bse/gslosctable.h
@@ -18,6 +18,7 @@
#define __GSL_OSC_TABLE_H__
#include <bse/gsldefs.h>
+#include <sfi/gbsearcharray.h>
G_BEGIN_DECLS
@@ -41,7 +42,7 @@ typedef struct
{
gfloat mix_freq;
GslOscWaveForm wave_form;
- gpointer entry_array;
+ GBSearchArray *entry_array;
} GslOscTable;
typedef struct
diff --git a/bse/gslvorbis-cutter.c b/bse/gslvorbis-cutter.cc
similarity index 95%
rename from bse/gslvorbis-cutter.c
rename to bse/gslvorbis-cutter.cc
index f088bd8..2312059 100644
--- a/bse/gslvorbis-cutter.c
+++ b/bse/gslvorbis-cutter.cc
@@ -87,11 +87,11 @@ static void
enqueue_page (SfiRing **dblocks,
ogg_page *opage)
{
- CDataBlock *dblock = g_malloc (sizeof (CDataBlock) - sizeof (dblock->data[0]) + opage->header_len);
+ CDataBlock *dblock = (CDataBlock*) g_malloc (sizeof (CDataBlock) - sizeof (dblock->data[0]) + opage->header_len);
dblock->length = opage->header_len;
memcpy (dblock->data, opage->header, dblock->length);
*dblocks = sfi_ring_append (*dblocks, dblock);
- dblock = g_malloc (sizeof (CDataBlock) - sizeof (dblock->data[0]) + opage->body_len);
+ dblock = (CDataBlock*) g_malloc (sizeof (CDataBlock) - sizeof (dblock->data[0]) + opage->body_len);
dblock->length = opage->body_len;
memcpy (dblock->data, opage->body, dblock->length);
*dblocks = sfi_ring_append (*dblocks, dblock);
@@ -104,7 +104,7 @@ gsl_vorbis_cutter_new (void)
{
GslVorbisCutter *self = g_new0 (GslVorbisCutter, 1);
self->cutpoint = 0;
- self->cutmode = 0;
+ self->cutmode = GSL_VORBIS_CUTTER_NONE;
self->eos = FALSE;
self->dblock_offset = 0;
self->dblocks = NULL;
@@ -219,7 +219,7 @@ gsl_vorbis_cutter_read_ogg (GslVorbisCutter *self,
while (n_bytes && self->dblocks)
{
- CDataBlock *dblock = self->dblocks->data;
+ CDataBlock *dblock = (CDataBlock*) self->dblocks->data;
guint l = MIN (n_bytes, dblock->length - self->dblock_offset);
memcpy (bytes, dblock->data + self->dblock_offset, l);
n_bytes -= l;
@@ -300,7 +300,7 @@ vorbis_cutter_process_paket (GslVorbisCutter *self,
if (self->n_packets > 3) /* audio packet */
{
gboolean last_on_page = FALSE;
- DEBUG ("packet[%d]: b_o_s=%ld e_o_s=%ld packetno=%lld pgran=%lld granule=%lld", self->n_packets - 1,
+ DEBUG ("packet[%d]: b_o_s=%ld e_o_s=%ld packetno=%ld pgran=%ld granule=%ld", self->n_packets - 1,
opacket->b_o_s, opacket->e_o_s,
opacket->packetno, opacket->granulepos,
self->tracking_granule);
@@ -335,7 +335,7 @@ vorbis_cutter_process_paket (GslVorbisCutter *self,
}
}
else
- DEBUG ("packet[%d]: b_o_s=%ld e_o_s=%ld packetno=%lld pgran=%lld", self->n_packets - 1,
+ DEBUG ("packet[%d]: b_o_s=%ld e_o_s=%ld packetno=%ld pgran=%ld", self->n_packets - 1,
opacket->b_o_s, opacket->e_o_s,
opacket->packetno, opacket->granulepos);
/* copy packet to output stream */
@@ -382,7 +382,7 @@ gsl_vorbis_cutter_write_ogg (GslVorbisCutter *self,
if (!self->eos)
{
ogg_page opage;
- guint8 *buffer = ogg_sync_buffer (&self->isync, n_bytes);
+ guint8 *buffer = (guint8*) ogg_sync_buffer (&self->isync, n_bytes);
memcpy (buffer, bytes, n_bytes);
ogg_sync_wrote (&self->isync, n_bytes);
/* process incoming data page wise */
diff --git a/bse/gslvorbis-enc.c b/bse/gslvorbis-enc.cc
similarity index 95%
rename from bse/gslvorbis-enc.c
rename to bse/gslvorbis-enc.cc
index 21c8939..7f22bbc 100644
--- a/bse/gslvorbis-enc.c
+++ b/bse/gslvorbis-enc.cc
@@ -65,11 +65,11 @@ static void
gsl_vorbis_encoder_enqueue_page (GslVorbisEncoder *self,
ogg_page *opage)
{
- EDataBlock *dblock = g_malloc (sizeof (EDataBlock) - sizeof (dblock->data[0]) + opage->header_len);
+ EDataBlock *dblock = (EDataBlock*) g_malloc (sizeof (EDataBlock) - sizeof (dblock->data[0]) + opage->header_len);
dblock->length = opage->header_len;
memcpy (dblock->data, opage->header, dblock->length);
self->dblocks = sfi_ring_append (self->dblocks, dblock);
- dblock = g_malloc (sizeof (EDataBlock) - sizeof (dblock->data[0]) + opage->body_len);
+ dblock = (EDataBlock*) g_malloc (sizeof (EDataBlock) - sizeof (dblock->data[0]) + opage->body_len);
dblock->length = opage->body_len;
memcpy (dblock->data, opage->body, dblock->length);
self->dblocks = sfi_ring_append (self->dblocks, dblock);
@@ -115,8 +115,8 @@ gsl_vorbis_encoder_add_comment (GslVorbisEncoder *self,
g_return_if_fail (self != NULL);
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (comment != NULL);
-
- vorbis_comment_add (&self->vcomment, (gpointer) comment);
+
+ vorbis_comment_add (&self->vcomment, comment);
}
void
@@ -128,17 +128,17 @@ gsl_vorbis_encoder_add_named_comment (GslVorbisEncoder *self,
g_return_if_fail (self->stream_setup == FALSE);
g_return_if_fail (tag_name != NULL);
g_return_if_fail (comment != NULL);
-
- vorbis_comment_add_tag (&self->vcomment, (gpointer) tag_name, (gpointer) comment);
+
+ vorbis_comment_add_tag (&self->vcomment, tag_name, comment);
}
-static gchar*
-convert_latin1_to_utf8 (const gchar *string)
+static char*
+convert_latin1_to_utf8 (const char *string)
{
if (string)
{
- const guchar *s = string;
- guint l = strlen (s);
+ const guchar *s = (const guchar*) string;
+ uint l = strlen ((const char*) s);
guchar *dest = g_new (guchar, l * 2 + 1), *d = dest;
while (*s)
if (*s >= 0xC0)
@@ -148,7 +148,7 @@ convert_latin1_to_utf8 (const gchar *string)
else
*d++ = *s++;
*d++ = 0;
- return dest;
+ return (char*) dest;
}
return NULL;
}
@@ -181,7 +181,7 @@ gsl_vorbis_encoder_add_named_lcomment (GslVorbisEncoder *self,
g_return_if_fail (comment != NULL);
utf8_comment = convert_latin1_to_utf8 (comment);
- vorbis_comment_add_tag (&self->vcomment, (gpointer) tag_name, utf8_comment);
+ vorbis_comment_add_tag (&self->vcomment, tag_name, utf8_comment);
g_free (utf8_comment);
}
@@ -446,7 +446,7 @@ gsl_vorbis_encoder_read_ogg (GslVorbisEncoder *self,
gsl_vorbis_encoder_process (self);
while (n_bytes && self->dblocks)
{
- EDataBlock *dblock = self->dblocks->data;
+ EDataBlock *dblock = (EDataBlock*) self->dblocks->data;
guint l = MIN (n_bytes, dblock->length - self->dblock_offset);
memcpy (bytes, dblock->data + self->dblock_offset, l);
n_bytes -= l;
@@ -480,7 +480,7 @@ gsl_vorbis_encoder_version (void)
if (r != 0)
{
vorbis_info_clear (&vinfo);
- goto error_result;
+ return g_strdup ("unknown");
}
vorbis_dsp_state vdsp = { 0 };
vorbis_analysis_init (&vdsp, &vinfo);
@@ -515,6 +515,5 @@ gsl_vorbis_encoder_version (void)
/* return result */
if (vendor)
return vendor; // e.g. "Xiphophorus libVorbis I 20000508" (first beta) or "Xiph.Org libVorbis I 20020717" (1.0)
- error_result:
return g_strdup ("unknown");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]