annotate src/demac/plugin.c @ 2196:dfa3c3aa2dc7

switched to mowgli_dictionary from GHashTable
author Eugene Zagidullin <e.asphyx@gmail.com>
date Thu, 29 Nov 2007 03:09:13 +0300
parents 329267b09658
children 8b3c2fe608c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
1 /*
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
2 * Audacious Monkey's Audio plugin
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
3 *
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
4 * Copyright (C) Eugene Zagidullin 2007
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
5 *
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
6 * Used some code from libdemac and example application:
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
7 * Copyright (C) Dave Chapman 2007
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
8 *
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
12 * (at your option) any later version.
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
13 *
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
17 * GNU General Public License for more details.
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
18 *
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
22 *
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
23 */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
24
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
25 #ifndef _XOPEN_SOURCE
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
26 #define _XOPEN_SOURCE
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
27 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
28
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
29 #include "config.h"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
30
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
31 #include <ctype.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
32 #include <stdio.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
33
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
34 #include <stdlib.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
35 #include <errno.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
36 #include <string.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
37 #include <assert.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
38
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
39 #include <glib.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
40 #include <gtk/gtk.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
41 #include <glib/gprintf.h>
2196
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
42 #include <mowgli.h>
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
43
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
44 #include <audacious/i18n.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
45
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
46 #include <audacious/plugin.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
47 #include <audacious/main.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
48 #include <audacious/output.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
49 #include <audacious/vfs.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
50 #include <audacious/util.h>
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
51
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
52 #include "ape.h"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
53 #include "apev2.h"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
54
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
55 #ifndef MIN
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
56 #define MIN(a,b) ((a) < (b) ? (a) : (b))
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
57 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
58
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
59 #define MAX_BYTESPERSAMPLE 2 // currently only 16bps supported
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
60
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
61 static GThread *pb_thread;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
62 static gpointer demac_decode_loop(InputPlayback *pb);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
63 static Tuple *demac_get_tuple(char *filename);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
64 static Tuple *demac_probe_for_tuple (gchar *uri, VFSFile *vfd);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
65
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
66 static GMutex *demac_mutex;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
67 static unsigned long seek_to_msec=(unsigned long)-1; /* -1 == not needed */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
68
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
69 static InputPlugin demac_ip;
2191
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2190
diff changeset
70 static GtkWidget *about_window = NULL;
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
71
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
72 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
73 # include "crc.c"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
74 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
75
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
76 static gboolean demac_probe_vfs(char *filename, VFSFile* input_file) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
77 APEContext *ctx;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
78
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
79 ctx = calloc(sizeof(APEContext), 1);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
80 if(ape_read_header(ctx, input_file, 1) < 0) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
81 free(ctx);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
82 aud_vfs_rewind(input_file); /* Do we really need it? */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
83 return FALSE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
84 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
85
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
86 free(ctx);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
87
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
88 aud_vfs_rewind(input_file); /* Do we really need it? */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
89
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
90 return TRUE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
91 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
92
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
93 static void demac_play(InputPlayback *pb) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
94 pb->playing = 1;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
95 pb->eof = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
96 pb->error = FALSE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
97 pb_thread = g_thread_self();
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
98 pb->set_pb_ready(pb);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
99
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
100 demac_decode_loop(pb);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
101 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
102
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
103 static void demac_do_mseek(APEContext *ctx, unsigned long msec) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
104 if(ctx->seektable) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
105 unsigned int framecount = msec * ((unsigned long long)ctx->totalframes - 1L) / ctx->duration;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
106 ctx->currentframe = framecount;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
107 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
108 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
109
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
110 gpointer demac_decode_loop(InputPlayback *pb) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
111 VFSFile *vfd;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
112 uint8_t *frame_buf = NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
113 guint8 *wav = NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
114 int wav_buffer_size;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
115 gchar *title = NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
116 int audio_opened = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
117 int playing;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
118 unsigned long local_seek_to;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
119 APEContext *ctx = NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
120 APEDecoderContext *dec = NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
121 int decoded_bytes;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
122 int pkt_size, bytes_used;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
123 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
124 uint32_t frame_crc;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
125 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
126
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
127 if ((vfd = aud_vfs_fopen(pb->filename, "r")) == NULL) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
128 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
129 fprintf(stderr, "** demac: plugin.c: Error opening URI: %s\n", pb->filename);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
130 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
131 pb->error = TRUE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
132 goto cleanup;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
133 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
134
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
135 ctx = calloc(sizeof(APEContext), 1);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
136 if(ape_read_header(ctx, vfd, 0) < 0) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
137 pb->error = TRUE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
138 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
139 fprintf(stderr, "** demac: plugin.c: Cannot parse APE header or unsupported format: %s\n", pb->filename);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
140 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
141 goto cleanup;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
142 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
143
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
144 dec = calloc(sizeof(APEDecoderContext), 1);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
145 if(ape_decode_init(dec, ctx) < 0) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
146 pb->error = TRUE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
147 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
148 fprintf(stderr, "** demac: plugin.c: Error initializing decoder\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
149 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
150 goto cleanup;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
151 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
152
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
153 frame_buf = malloc(ctx->max_packet_size);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
154
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
155 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
156 fprintf(stderr, "** demac: plugin.c: Duration: %u msec\n", ctx->duration);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
157 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
158
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
159 if(!pb->output->open_audio(FMT_S16_LE, ctx->samplerate, ctx->channels)) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
160 pb->error = TRUE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
161 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
162 fprintf(stderr, "** demac: plugin.c: Cannot open audio.\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
163 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
164 goto cleanup;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
165 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
166
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
167 audio_opened = 1;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
168
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
169 Tuple *tpl = demac_probe_for_tuple (pb->filename, vfd);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
170 title = aud_tuple_formatter_make_title_string(tpl, aud_get_gentitle_format());
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
171 pb->set_params(pb, title, ctx->duration, -1, ctx->samplerate, ctx->channels);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
172 aud_tuple_free(tpl);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
173
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
174 /* begin decoding */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
175 wav_buffer_size = ctx->blocksperframe * MAX_BYTESPERSAMPLE * ctx->channels;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
176 wav = malloc(wav_buffer_size);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
177
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
178 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
179 playing = pb->playing;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
180 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
181
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
182 while (playing && (ctx->currentframe < ctx->totalframes))
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
183 {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
184 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
185 playing = pb->playing;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
186 local_seek_to = seek_to_msec;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
187 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
188
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
189 /* do seeking */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
190 if (local_seek_to != -1) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
191 demac_do_mseek(ctx, local_seek_to);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
192 pb->output->flush(local_seek_to);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
193
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
194 local_seek_to = -1;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
195 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
196 seek_to_msec = -1;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
197 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
198
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
199 /* reset decoder */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
200 dec->samples = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
201 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
202
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
203 ape_read_packet(ctx, vfd, frame_buf, &pkt_size);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
204 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
205 assert(pkt_size <= ctx->max_packet_size);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
206 frame_crc = ape_initcrc();
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
207 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
208 bytes_used = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
209
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
210 /*#ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
211 fprintf(stderr, "frame %d, %d samples, offset %d, size %d\n", ctx->currentframe-1,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
212 *((uint32_t*)frame_buf), *((uint32_t*)(frame_buf+4)), pkt_size);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
213 #endif*/
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
214
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
215 /* Decode the frame a chunk at a time */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
216 while (playing && (bytes_used != pkt_size) && (local_seek_to == -1))
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
217 {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
218 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
219 playing = pb->playing;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
220 local_seek_to = seek_to_msec;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
221 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
222
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
223 decoded_bytes = wav_buffer_size;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
224 bytes_used = ape_decode_frame(dec, wav, &decoded_bytes, frame_buf, pkt_size);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
225 if(bytes_used < 0) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
226 /* skip frame */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
227 dec->samples = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
228 break;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
229 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
230
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
231 if(local_seek_to != -1) break;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
232
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
233 /* Write audio data */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
234 pb->pass_audio(pb, FMT_S16_LE, ctx->channels, decoded_bytes, wav, &playing);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
235 #if DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
236 frame_crc = ape_updatecrc(wav, decoded_bytes, frame_crc);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
237 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
238
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
239 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
240
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
241 #if DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
242 frame_crc = ape_finishcrc(frame_crc);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
243
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
244 if (dec->CRC != frame_crc) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
245 fprintf(stderr, "** demac: plugin.c: CRC error in frame %d\n", ctx->currentframe-1);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
246 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
247 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
248 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
249
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
250 cleanup:
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
251
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
252 pb->eof = TRUE;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
253 pb->playing = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
254
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
255 if(title) g_free(title);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
256 if(audio_opened) pb->output->close_audio();
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
257
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
258 if(dec) {ape_decode_close(dec); free(dec);}
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
259 if(wav) free(wav);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
260 if(frame_buf) free(frame_buf);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
261 if(ctx) {ape_read_close(ctx); free(ctx);}
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
262 if(vfd) aud_vfs_fclose(vfd);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
263
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
264 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
265 fprintf(stderr, "** demac: plugin.c: decoding loop finished\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
266 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
267
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
268 return NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
269 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
270
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
271 static void demac_stop(InputPlayback *pb)
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
272 {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
273 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
274 int playing = pb->playing;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
275 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
276
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
277 if (playing) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
278 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
279 pb->playing = 0;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
280 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
281 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
282 fprintf(stderr, "** demac: plugin.c: waiting for thread finished\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
283 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
284 //g_thread_join(pb->thread);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
285 /* pb->thread is useless if input plugin initialized from **terrible** cue-sheet plugin */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
286 g_thread_join(pb_thread);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
287 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
288 fprintf(stderr, "** demac: plugin.c: thread finished\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
289 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
290 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
291 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
292
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
293 static void demac_pause(InputPlayback *pb, short paused) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
294 pb->output->pause(paused);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
295 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
296
2196
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
297 static void destroy_cb(mowgli_dictionary_elem_t *delem, void *privdata) {
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
298 g_free(delem->data);
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
299 }
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
300
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
301 Tuple *demac_probe_for_tuple (gchar *uri, VFSFile *vfd) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
302 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
303 fprintf(stderr, "** demac: plugin.c: demac_probe_for_tuple()\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
304 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
305 Tuple *tpl = aud_tuple_new_from_filename(uri);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
306 gchar codec_string[32];
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
307
2196
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
308 mowgli_dictionary_t *tag = NULL;
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
309 gchar *item;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
310 if ((tag = parse_apev2_tag(vfd)) != NULL) {
2196
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
311 if((item = mowgli_dictionary_retrieve(tag, "Artist")) != NULL) aud_tuple_associate_string(tpl, FIELD_ARTIST, NULL, item);
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
312 if((item = mowgli_dictionary_retrieve(tag, "Title")) != NULL) aud_tuple_associate_string(tpl, FIELD_TITLE, NULL, item);
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
313 if((item = mowgli_dictionary_retrieve(tag, "Album")) != NULL) aud_tuple_associate_string(tpl, FIELD_ALBUM, NULL, item);
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
314 if((item = mowgli_dictionary_retrieve(tag, "Comment")) != NULL) aud_tuple_associate_string(tpl, FIELD_COMMENT, NULL, item);
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
315 if((item = mowgli_dictionary_retrieve(tag, "Genre")) != NULL) aud_tuple_associate_string(tpl, FIELD_GENRE, NULL, item);
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
316 if((item = mowgli_dictionary_retrieve(tag, "Track")) != NULL) aud_tuple_associate_int(tpl, FIELD_TRACK_NUMBER, NULL, atoi(item));
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
317 if((item = mowgli_dictionary_retrieve(tag, "Year")) != NULL) aud_tuple_associate_int(tpl, FIELD_YEAR, NULL, atoi(item));
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
318 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
319
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
320 APEContext *ctx = calloc(sizeof(APEContext), 1);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
321 aud_vfs_rewind(vfd);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
322 ape_read_header(ctx, vfd, 1);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
323 aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
324 ape_read_close(ctx);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
325 free(ctx);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
326
2196
dfa3c3aa2dc7 switched to mowgli_dictionary from GHashTable
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
327 if (tag) mowgli_dictionary_destroy(tag, destroy_cb, NULL);
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
328
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
329 g_sprintf(codec_string, "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
330 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
331 fprintf(stderr, "** demac: plugin.c: Codec: %s\n", codec_string);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
332 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
333 aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
334 aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless");
2189
549009824758 demac: added MIME type (audio/x-ape) to provided tuple
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2182
diff changeset
335 aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape");
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
336 return tpl;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
337 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
338
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
339 Tuple *demac_get_tuple(char *filename) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
340 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
341 fprintf(stderr, "** demac: plugin.c: demac_get_tuple()\n");
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
342 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
343 VFSFile *vfd;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
344
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
345 if ((vfd = aud_vfs_fopen(filename, "r")) == NULL) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
346 return NULL;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
347 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
348
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
349 Tuple *tpl = demac_probe_for_tuple(filename, vfd);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
350 aud_vfs_fclose(vfd);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
351 return tpl;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
352 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
353
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
354 static void demac_mseek (InputPlayback *pb, gulong millisecond) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
355 g_mutex_lock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
356 seek_to_msec = millisecond;
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
357 g_mutex_unlock(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
358 #ifdef DEBUG
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
359 fprintf(stderr, "** demac: plugin.c: seeking to %u msec\n", millisecond);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
360 #endif
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
361 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
362
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
363 static void demac_seek (InputPlayback *pb, gint time) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
364 demac_mseek(pb, (unsigned long)time*1000);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
365 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
366
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
367 static void demac_init() {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
368 /* Found in Freedesktop shared-mime-info */
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
369 aud_mime_set_plugin("audio/x-ape", &demac_ip);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
370 demac_mutex = g_mutex_new();
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
371 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
372
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
373 static void demac_cleanup() {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
374 g_mutex_free(demac_mutex);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
375 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
376
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
377 static void demac_about(void) {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
378
2191
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2190
diff changeset
379 if (about_window) {
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2190
diff changeset
380 gtk_window_present(GTK_WINDOW(about_window));
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2190
diff changeset
381 } else {
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
382 about_window = audacious_info_dialog(_("About Monkey's Audio Plugin"),
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
383 _("Copyright (C) 2007 Eugene Zagidullin <e.asphyx@gmail.com>\n"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
384 "Based on ffape decoder, Copyright (C) 2007 Benjamin Zores\n"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
385 "ffape itself based on libdemac by Dave Chapman\n\n"
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
386 "ffape is a part of FFmpeg project, http://ffmpeg.mplayerhq.hu/"),
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
387 _("Ok"), FALSE, NULL, NULL);
2191
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2190
diff changeset
388 g_signal_connect(G_OBJECT(about_window), "destroy", G_CALLBACK(gtk_widget_destroyed), &about_window);
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
389 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
390 }
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
391
2190
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
392 static gboolean demac_update_song_tuple(Tuple *tuple, VFSFile *vfd) {
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
393 fprintf(stderr, "demac_update_song_tuple(): stub\n");
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
394 fprintf(stderr, "Title: %s\n", aud_tuple_get_string(tuple, FIELD_TITLE, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
395 fprintf(stderr, "Artist: %s\n", aud_tuple_get_string(tuple, FIELD_ARTIST, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
396 fprintf(stderr, "Album: %s\n", aud_tuple_get_string(tuple, FIELD_ALBUM, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
397 fprintf(stderr, "Comment: %s\n", aud_tuple_get_string(tuple, FIELD_COMMENT, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
398 fprintf(stderr, "Genre: %s\n", aud_tuple_get_string(tuple, FIELD_GENRE, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
399 fprintf(stderr, "Year: %d\n", aud_tuple_get_int(tuple, FIELD_YEAR, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
400 fprintf(stderr, "Track: %d\n", aud_tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
401
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
402 return TRUE;
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
403 }
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
404
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
405 static gchar *fmts[] = { "ape", NULL };
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
406
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
407 static InputPlugin demac_ip = {
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
408 .description = "Monkey's Audio Plugin",
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
409 .init = demac_init,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
410 .about = demac_about,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
411 .play_file = demac_play,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
412 .stop = demac_stop,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
413 .pause = demac_pause,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
414 .seek = demac_seek,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
415 .cleanup = demac_cleanup,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
416 .get_song_tuple = demac_get_tuple,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
417 .is_our_file_from_vfs = demac_probe_vfs,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
418 .vfs_extensions = fmts,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
419 .mseek = demac_mseek,
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
420 .probe_for_tuple = demac_probe_for_tuple,
2190
36b9f3e6cbcf demac: added stub for update_song_tuple() for debugging purposes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2189
diff changeset
421 .update_song_tuple = demac_update_song_tuple,
2182
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
422 };
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
423
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
424 InputPlugin *demac_iplist[] = { &demac_ip, NULL };
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
425 DECLARE_PLUGIN(demac, NULL, NULL, demac_iplist, NULL, NULL, NULL, NULL, NULL);
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
426
cc5e9ec110a4 Added initial version of Monkey's Audio plugin
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
diff changeset
427 /* vim:foldmethod=syntax: */