annotate src/wav/wav-sndfile.c @ 731:645849c1e725 trunk

[svn] - add a (hidden for now) configuration option, use_local_ip and local_ip which plugins can use to bind to a specific IP/interface.
author nenolod
date Mon, 26 Feb 2007 03:38:03 -0800
parents 836cbe95ec5d
children baa22cb0216d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Copyright (C) 2005 Audacious development team.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 * Based on the xmms_sndfile input plugin:
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 * Copyright (C) 2000, 2002 Erik de Castro Lopo
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
22 /*
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
23 * Rewritten 17-Feb-2007 (nenolod):
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
24 * - now uses conditional variables to ensure that sndfile mutex is
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
25 * entirely protected.
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
26 * - pausing works now
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
27 * - fixed some potential race conditions when dealing with NFS.
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
28 * - TITLE_LEN removed
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
29 */
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
30
528
4d8b92b55acf [svn] - add config.h includes where needed
nenolod
parents: 527
diff changeset
31 #ifdef HAVE_CONFIG_H
4d8b92b55acf [svn] - add config.h includes where needed
nenolod
parents: 527
diff changeset
32 # include "config.h"
4d8b92b55acf [svn] - add config.h includes where needed
nenolod
parents: 527
diff changeset
33 #endif
4d8b92b55acf [svn] - add config.h includes where needed
nenolod
parents: 527
diff changeset
34
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37 #include <math.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
38 #include <stdio.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
39
565
c2f3df58cad6 [svn] - make this compile again
nenolod
parents: 561
diff changeset
40 #include <audacious/plugin.h>
4
0ad4849f6219 [svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents: 0
diff changeset
41 #include <audacious/util.h>
0ad4849f6219 [svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents: 0
diff changeset
42 #include <audacious/titlestring.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 12
diff changeset
43 #include <audacious/i18n.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 #include "audacious/output.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45 #include "wav-sndfile.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
46
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47 #include <sndfile.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49 static SNDFILE *sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
50 static SF_INFO sfinfo;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52 static int song_length;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
53 static int bit_rate = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
54 static int seek_time = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
56 static GThread *decode_thread;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
57 static GMutex *decode_start_mutex;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
58 static GMutex *decode_mutex;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
59 static GCond *decode_start_cond;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
60 static GCond *decode_cond;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
62 InputPlugin wav_ip = {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
63 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
64 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
65 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
66 plugin_init,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
67 wav_about,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
68 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
69 is_our_file,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
70 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
71 play_start,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
72 play_stop,
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
73 play_pause,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
74 file_seek,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
75 NULL,
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
76 NULL,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
77 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
78 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
79 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
80 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
81 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
83 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
84 get_song_info,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
85 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
86 NULL
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 int
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90 get_song_length (char *filename)
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
91 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
92 SNDFILE *tmp_sndfile;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93 SF_INFO tmp_sfinfo;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
94
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95 if (! (tmp_sndfile = sf_open (filename, SFM_READ, &tmp_sfinfo)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
96 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
97
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
98 sf_close (tmp_sndfile);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
99 tmp_sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
100
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
101 if (tmp_sfinfo.samplerate <= 0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
102 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
103
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
104 return (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
105 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
106
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
107 static gchar *get_title(char *filename)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
108 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
109 gchar *title;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
110 title = g_path_get_basename(filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
111 return title;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
112 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
113
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
114 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
115 plugin_init (void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
116 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
117 seek_time = -1;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
118
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
119 decode_start_mutex = g_mutex_new();
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
120 decode_mutex = g_mutex_new();
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
121
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
122 decode_start_cond = g_cond_new();
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
123 decode_cond = g_cond_new();
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
124 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
125
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
126 static int
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
127 is_our_file (char *filename)
664
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
128 {
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
129 SNDFILE *tmp_sndfile;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
130 SF_INFO tmp_sfinfo;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
131
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
132 /* Have to open the file to see if libsndfile can handle it. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
133 if (! (tmp_sndfile = sf_open (filename, SFM_READ, &tmp_sfinfo)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
134 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
135
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
136 /* It can so close file and return TRUE. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
137 sf_close (tmp_sndfile);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
138 tmp_sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
139
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
140 return TRUE;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
141 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
142
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
143 static gpointer
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
144 play_loop (gpointer arg)
664
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
145 {
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
146 static short buffer [BUFFER_SIZE];
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
147 int samples;
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
148 InputPlayback *playback = arg;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
149
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
150 for (;;)
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
151 {
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
152 GTimeVal sleeptime;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
153
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
154 g_get_current_time(&sleeptime);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
155 sleeptime.tv_usec += 10000;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
156 if (sleeptime.tv_usec >= 1000000)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
157 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
158 sleeptime.tv_sec += 1;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
159 sleeptime.tv_usec -= 1000000;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
160 }
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
161
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
162 g_mutex_lock(decode_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
163
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
164 /* sf_read_short will return 0 for all reads at EOF. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
165 samples = sf_read_short (sndfile, buffer, BUFFER_SIZE);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
166
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
167 if (samples > 0 && playback->playing == TRUE)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
168 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
169 while ((playback->output->buffer_free () <
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
170 (samples * sizeof (short))) &&
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
171 playback->playing == TRUE)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
172 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
173 g_cond_timed_wait(decode_cond,
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
174 decode_mutex, &sleeptime);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
175
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
176 if (playback->playing == FALSE)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
177 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
178 g_mutex_unlock(decode_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
179 break;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
180 }
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
181 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
183 produce_audio (playback->output->written_time (), FMT_S16_NE, sfinfo.channels,
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
184 samples * sizeof (short), buffer, &playback->playing);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
185
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
186 g_cond_signal(decode_start_cond);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
187 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
188 else
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
189 {
667
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
190 playback->eof = TRUE;
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
191 playback->playing = FALSE;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
192
667
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
193 g_mutex_unlock(decode_mutex);
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
194 break;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
195 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
196
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
197 /* Do seek if seek_time is valid. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198 if (seek_time > 0)
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
199 {
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
200 sf_seek (sndfile, seek_time * sfinfo.samplerate, SEEK_SET);
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
201 playback->output->flush (seek_time * 1000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
202 seek_time = -1;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
203 }
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
204
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
205 g_cond_timed_wait(decode_cond,
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
206 decode_mutex, &sleeptime);
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
207
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
208 if (playback->playing == FALSE)
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
209 {
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
210 g_mutex_unlock(decode_mutex);
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
211 break;
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
212 }
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
213
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
214 g_mutex_unlock(decode_mutex);
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
215 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
216
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
217 sf_close (sndfile);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
218 sndfile = NULL;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
219 seek_time = -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
220
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
221 playback->output->close_audio();
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
222
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223 g_thread_exit (NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
224 return NULL;
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
225 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
228 play_start (InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
230 char *filename = playback->filename;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
231 int pcmbitwidth;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
232 gchar *song_title;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
233
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 if (sndfile)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
235 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
237 pcmbitwidth = 32;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239 song_title = get_title(filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241 if (! (sndfile = sf_open (filename, SFM_READ, &sfinfo)))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
242 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
243
664
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
244 bit_rate = sfinfo.samplerate * pcmbitwidth;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246 if (sfinfo.samplerate > 0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
247 song_length = (int) ceil (1000.0 * sfinfo.frames / sfinfo.samplerate);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
248 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
249 song_length = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
251 if (! playback->output->open_audio (FMT_S16_NE, sfinfo.samplerate, sfinfo.channels))
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
252 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
253 sf_close (sndfile);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254 sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255 return;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
256 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
257
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
258 wav_ip.set_info (song_title, song_length, bit_rate, sfinfo.samplerate, sfinfo.channels);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259 g_free (song_title);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
260
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
261 playback->playing = TRUE;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
262
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
263 decode_thread = g_thread_create ((GThreadFunc)play_loop, playback, TRUE, NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
264
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
265 g_mutex_lock(decode_start_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
266 g_cond_wait(decode_start_cond, decode_start_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
267 g_mutex_unlock(decode_start_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
268 }
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
269
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
270 static void
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
271 play_pause (InputPlayback *playback, gshort p)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
272 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
273 playback->output->pause(p);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
274 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
275
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
276 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
277 play_stop (InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
278 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
279 if (decode_thread == NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
280 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
281
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
282 g_mutex_lock(decode_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
283 playback->playing = FALSE;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
284 g_mutex_unlock(decode_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
285 g_cond_signal(decode_cond);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
287 g_thread_join (decode_thread);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
288
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
290 decode_thread = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 seek_time = -1;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
292 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
293
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
295 file_seek (InputPlayback *playback, int time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
296 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
297 if (! sfinfo.seekable)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
298 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
300 seek_time = time;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
302 while (seek_time != -1)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
303 xmms_usleep (80000);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
304 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
306 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307 get_song_info (char *filename, char **title, int *length)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309 (*length) = get_song_length(filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310 (*title) = get_title(filename);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
311 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
312
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
313 static void wav_about(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
314 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
315 static GtkWidget *box;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
316 if (!box)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
317 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
318 box = xmms_show_message(
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319 _("About sndfile WAV support"),
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
320 _("Adapted for Audacious usage by Tony Vroon <chainsaw@gentoo.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
321 "from the xmms_sndfile plugin which is:\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322 "Copyright (C) 2000, 2002 Erik de Castro Lopo\n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
323 "This program is free software ; you can redistribute it and/or modify \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
324 "it under the terms of the GNU General Public License as published by \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
325 "the Free Software Foundation ; either version 2 of the License, or \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 "(at your option) any later version. \n \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
327 "This program is distributed in the hope that it will be useful, \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328 "but WITHOUT ANY WARRANTY ; without even the implied warranty of \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
329 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330 "See the GNU General Public License for more details. \n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
331 "You should have received a copy of the GNU General Public \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332 "License along with this program ; if not, write to \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
333 "the Free Software Foundation, Inc., \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
334 "51 Franklin Street, Fifth Floor, \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 "Boston, MA 02110-1301 USA"),
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336 _("Ok"), FALSE, NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337 g_signal_connect(G_OBJECT(box), "destroy",
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 (GCallback)gtk_widget_destroyed, &box);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
340 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 InputPlugin *get_iplugin_info(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345 wav_ip.description = g_strdup_printf(_("sndfile WAV plugin"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
346 return &wav_ip;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
347 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
348