encode_file (argv [1], "imaadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ;
encode_file (argv [1], "msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
encode_file (argv [1], "gsm610.wav" , SF_FORMAT_WAV | SF_FORMAT_GSM610) ;
+#if 0 /* For temporal testing of encoding ogg/vorbis functionality */
+ encode_file (argv [1], "pcm16.ogg" , SF_FORMAT_OGG | SF_FORMAT_VORBIS) ;
+#endif
/* Soundforge W64. */
encode_file (argv [1], "pcmu8.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ;
%build
%define warn_flags -W -Wall -Wstrict-prototypes -Wpointer-arith -Wno-unused-parameter
autoreconf --force --install
-CFLAGS="%{optflags} %{warn_flags}"
+CFLAGS="%{optflags} %{warn_flags} -D__TIZEN__"
export CFLAGS
+LDFLAGS="-ldl"
+export LDFLAGS
%configure --disable-static \
--disable-dependency-tracking \
--disable-sqlite --disable-alsa
#if HAVE_EXTERNAL_LIBS
+
#include <ogg/ogg.h>
#include <vorbis/codec.h>
-#if ENABLE_VORBIS_ENC /* default disabled for memory optimization */
+
+#ifdef __TIZEN__
+#include <dlfcn.h> /* for dlopen */
+#else
#include <vorbis/vorbisenc.h>
#endif
/* Encoding quality in range [0.0, 1.0]. */
double quality ;
+
+#ifdef __TIZEN__
+ /* func ptr for encoder */
+ void *dl;
+#endif
} VORBIS_PRIVATE ;
static int
return 0 ;
} /* vorbis_read_header */
+
+#ifdef __TIZEN__
+#define VORBIS_ENC_SO_NAME "/usr/lib/libvorbisenc.so.2" /* FIXME : Any good way to avoid hardcoding? */
+#define VORBIS_ENC_INIT_VBR "vorbis_encode_init_vbr"
+
+static int
+_vorbis_encode_init(SF_PRIVATE *psf)
+{
+ int (*fn) (vorbis_info *, long, long, float);
+ void *dl = NULL;
+ VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
+
+ /* load so */
+ dl = dlopen(VORBIS_ENC_SO_NAME, RTLD_GLOBAL | RTLD_NOW);
+ if (!dl) {
+ psf_log_printf (psf, "failed to dlopen [%s], error [%s]\n", VORBIS_ENC_SO_NAME, dlerror());
+ return -1;
+ }
+ dlerror();
+
+ vdata->dl = dl;
+
+ /* load symbol */
+ fn = dlsym(dl, VORBIS_ENC_INIT_VBR);
+ if (!fn) {
+ psf_log_printf (psf, "failed to dlsym [%s], error [%s]\n", VORBIS_ENC_INIT_VBR, dlerror());
+ return -1;
+ }
+ dlerror();
+
+ /* call function */
+ return fn(&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality);
+}
+#endif /* __TIZEN__ */
+
static int
vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{
vorbis_info_init (&vdata->vinfo) ;
/* The style of encoding should be selectable here, VBR quality mode. */
-#if ENABLE_VORBIS_ENC
+#ifdef __TIZEN__
+ ret = _vorbis_encode_init(psf);
+#else
ret = vorbis_encode_init_vbr (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality) ;
#endif
vorbis_comment_clear (&vdata->vcomment) ;
vorbis_info_clear (&vdata->vinfo) ;
+#ifdef __TIZEN__
+ if (vdata->dl) {
+ dlclose(vdata->dl);
+ vdata->dl = NULL;
+ }
+#endif
+
return 0 ;
} /* vorbis_close */