changeset 991:67cf9a1e3dc5 trunk

[svn] - commit what i have, presently broken
author nenolod
date Tue, 01 May 2007 08:07:48 -0700
parents 238055a6cb8f
children a277aaab4525
files ChangeLog src/filewriter/Makefile src/filewriter/filewriter.c src/filewriter/flac.c src/filewriter/plugins.h
diffstat 5 files changed, 169 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue May 01 07:03:49 2007 -0700
+++ b/ChangeLog	Tue May 01 08:07:48 2007 -0700
@@ -1,3 +1,17 @@
+2007-05-01 14:03:49 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [2120]
+  - remove support for hatena music as hatena ceased their musical profile service.
+  
+  trunk/src/scrobbler/Makefile    |    3 
+  trunk/src/scrobbler/configure.c |   66 --
+  trunk/src/scrobbler/gerpok.c    |    2 
+  trunk/src/scrobbler/hatena.c    |  909 ----------------------------------------
+  trunk/src/scrobbler/hatena.h    |   13 
+  trunk/src/scrobbler/plugin.c    |   49 --
+  trunk/src/scrobbler/scrobbler.c |    2 
+  7 files changed, 12 insertions(+), 1032 deletions(-)
+
+
 2007-05-01 05:03:19 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [2118]
   - provide full metadata from the file's tuple when performing the transcode
--- a/src/filewriter/Makefile	Tue May 01 07:03:49 2007 -0700
+++ b/src/filewriter/Makefile	Tue May 01 08:07:48 2007 -0700
@@ -5,8 +5,8 @@
 
 LIBDIR = $(plugindir)/$(OUTPUT_PLUGIN_DIR)
 
-LIBADD = $(GTK_LIBS) -lmp3lame -lvorbisenc
-SOURCES = filewriter.c wav.c mp3.c vorbis.c
+LIBADD = $(GTK_LIBS) -lmp3lame -lvorbisenc -lFLAC
+SOURCES = filewriter.c wav.c mp3.c vorbis.c flac.c
 
 OBJECTS = ${SOURCES:.c=.o}
 
--- a/src/filewriter/filewriter.c	Tue May 01 07:03:49 2007 -0700
+++ b/src/filewriter/filewriter.c	Tue May 01 08:07:48 2007 -0700
@@ -28,9 +28,9 @@
 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel;
 
 static GtkWidget *fileext_hbox, *fileext_label, *fileext_combo, *plugin_button;
-enum fileext_t { WAV = 0, MP3, VORBIS, FILEEXT_MAX } ;
+enum fileext_t { WAV = 0, MP3, VORBIS, FLAC, FILEEXT_MAX } ;
 static gint fileext = WAV;
-static gchar *fileext_str[] = { "wav", "mp3", "ogg" } ;
+static gchar *fileext_str[] = { "wav", "mp3", "ogg", "flac" } ;
 static FileWriter plugin;
 
 static GtkWidget *saveplace_hbox, *saveplace;
@@ -104,6 +104,8 @@
         plugin = mp3_plugin;
     if (fileext == VORBIS)
         plugin = vorbis_plugin;
+    if (fileext == FLAC)
+        plugin = flac_plugin;
 }
 
 static void file_init(void)
@@ -494,6 +496,7 @@
         gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "WAV");
         gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "MP3");
         gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "Vorbis");
+        gtk_combo_box_append_text(GTK_COMBO_BOX(fileext_combo), "FLAC");
         gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0);
         gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext);
         g_signal_connect(G_OBJECT(fileext_combo), "changed", G_CALLBACK(fileext_cb), NULL);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/filewriter/flac.c	Tue May 01 08:07:48 2007 -0700
@@ -0,0 +1,147 @@
+/*  FileWriter FLAC Plugin
+ *  Copyright (c) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
+ *
+ *  Partially derived from Og(g)re - Ogg-Output-Plugin:
+ *  Copyright (c) 2002 Lars Siebold <khandha5@gmx.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "plugins.h"
+#include <FLAC/stream_encoder.h>
+#include <stdlib.h>
+
+static gint flac_open(void);
+static void flac_write(gpointer data, gint length);
+static void flac_close(void);
+static gint flac_free(void);
+static gint flac_playing(void);
+static gint flac_get_written_time(void);
+
+FileWriter flac_plugin =
+{
+    NULL,
+    NULL,
+    flac_open,
+    flac_write,
+    flac_close,
+    flac_free,
+    flac_playing,
+    flac_get_written_time
+};
+
+static FLAC__StreamEncoder *flac_encoder;
+static guint64 olen = 0;
+
+static FLAC__StreamEncoderWriteStatus flac_write_cb(const FLAC__StreamEncoder *encoder,
+    const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, gpointer data)
+{
+    written += vfs_fwrite(buffer, bytes, 1, (VFSFile *) data);
+
+    return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
+}
+
+static FLAC__StreamEncoderSeekStatus flac_seek_cb(const FLAC__StreamEncoder *encoder,
+    FLAC__uint64 absolute_byte_offset, gpointer data)
+{
+    VFSFile *file = (VFSFile *) data;
+
+    if (vfs_fseek(file, absolute_byte_offset, SEEK_SET) < 0)
+        return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
+
+    return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
+}
+
+static FLAC__StreamEncoderTellStatus flac_tell_cb(const FLAC__StreamEncoder *encoder,
+    FLAC__uint64 *absolute_byte_offset, gpointer data)
+{
+    VFSFile *file = (VFSFile *) data;
+
+    *absolute_byte_offset = vfs_ftell(file);
+
+    return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
+}
+
+static gint flac_open(void)
+{
+    written = 0;
+    olen = 0;
+
+    flac_encoder = FLAC__stream_encoder_new();
+
+    FLAC__stream_encoder_set_channels(flac_encoder, input.channels);
+    FLAC__stream_encoder_set_sample_rate(flac_encoder, input.frequency);
+    FLAC__stream_encoder_init_stream(flac_encoder, flac_write_cb, flac_seek_cb, flac_tell_cb,
+				     NULL, output_file);
+
+    return 1;
+}
+
+static void flac_write(gpointer data, gint length)
+{
+    FLAC__int32 *encbuffer[2];
+    short int *tmpdata = data;
+    int i;
+
+    encbuffer[0] = g_new0(FLAC__int32, length / input.channels);
+    encbuffer[1] = g_new0(FLAC__int32, length / input.channels);
+
+    if (input.channels == 1)
+    {
+        for (i = 0; i < (length / 2); i++)
+        {
+            encbuffer[0][i] = tmpdata[i] / 32768.0;
+            encbuffer[1][i] = tmpdata[i] / 32768.0;
+        }
+    }
+    else
+    {
+        for (i = 0; i < (length / 4); i++)
+        {
+            encbuffer[0][i] = tmpdata[2 * i] / 32768.0;
+            encbuffer[1][i] = tmpdata[2 * i + 1] / 32768.0;
+        }
+    }
+
+    FLAC__stream_encoder_process(flac_encoder, encbuffer, length / (input.channels * 2));
+    olen += length;
+
+    g_free(encbuffer[0]);
+    g_free(encbuffer[1]);
+}
+
+static void flac_close(void)
+{
+    FLAC__stream_encoder_finish(flac_encoder);
+    FLAC__stream_encoder_delete(flac_encoder);
+}
+
+static gint flac_free(void)
+{
+    return 1000000;
+}
+
+static gint flac_playing(void)
+{
+    return 0;
+}
+
+static gint flac_get_written_time(void)
+{
+    if (input.frequency && input.channels)
+        return (gint) ((olen * 1000) / (input.frequency * 2 * input.channels));
+
+    return 0;
+}
--- a/src/filewriter/plugins.h	Tue May 01 07:03:49 2007 -0700
+++ b/src/filewriter/plugins.h	Tue May 01 08:07:48 2007 -0700
@@ -25,6 +25,6 @@
 
 #include "filewriter.h"
 
-extern FileWriter wav_plugin, mp3_plugin, vorbis_plugin;
+extern FileWriter wav_plugin, mp3_plugin, vorbis_plugin, flac_plugin;
 
 #endif