annotate Plugins/Output/crossfade/crossfade.c @ 395:0923a41170bb trunk

[svn] Add S3M support back after receiving a convincing testcase.
author chainsaw
date Sat, 07 Jan 2006 06:18:13 -0800
parents 8528a27ada8f
children 55dc40ff1aff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2 * XMMS Crossfade Plugin
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
3 * Copyright (C) 2000-2004 Peter Eisenlohr <peter@eisenlohr.org>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
4 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
5 * based on the original OSS Output Plugin
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
6 * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
7 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
11 * (at your option) any later version.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
12 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
16 * GNU General Public License for more details.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
17 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
21 * USA.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
22 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
23
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
25 # include "config.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
26 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
27
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
28 #include "crossfade.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
29 #include "configure.h"
338
8528a27ada8f [svn] Stop last few desperate attempts to hold on to GTK1+ includes.
chainsaw
parents: 309
diff changeset
30 #include "interface-2.0.h"
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
31 #include "monitor.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
32 #include "support.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
33 #include "effect.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
34 #include "format.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
35 #include "convert.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
36 #include "rate.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
37 #include "volume.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
38 #include "timing.h"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
39
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
40 #include <stdio.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
41 #include <string.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
42 #include <stdlib.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
43 #include <ctype.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
44
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
45 #ifdef HAVE_DLFCN_H
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
46 # include <dlfcn.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
47 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
48 #include <unistd.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
49 #include <signal.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
50 #include <sys/time.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
51 #include <sys/types.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
52 #include <sys/ioctl.h>
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
53
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
54
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
55 #undef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
56
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
57 /* output plugin callback prototypes */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
58 static void xfade_init ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
59 static void xfade_set_volume (int l, int r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
60 static void xfade_get_volume (int *l, int *r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
61 static gint xfade_open_audio (AFormat fmt, int rate, int nch);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
62 static void xfade_write_audio (void *ptr, int length);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
63 static void xfade_close_audio ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
64 static void xfade_flush (int time);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
65 static void xfade_pause (short paused);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
66 static gint xfade_buffer_free ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
67 static gint xfade_buffer_playing();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
68 static gint xfade_written_time ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
69 static gint xfade_output_time ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
70
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
71 /* output plugin callback table */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
72 static OutputPlugin xfade_op =
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
73 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
74 NULL,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
75 NULL,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
76 "Crossfade Plugin " VERSION,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
77 xfade_init,
309
b04ce1c98b6f [svn] Plugin cleanup functionality, via giacomo.
nenolod
parents: 268
diff changeset
78 NULL,
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
79 xfade_about,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
80 xfade_configure,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
81 xfade_get_volume,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
82 xfade_set_volume,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
83 xfade_open_audio,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
84 xfade_write_audio,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
85 xfade_close_audio,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
86 xfade_flush,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
87 xfade_pause,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
88 xfade_buffer_free,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
89 xfade_buffer_playing,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
90 xfade_output_time,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
91 xfade_written_time,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
92 };
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
93
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
94 /* internal prototypes */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
95 static void load_symbols ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
96 static void output_list_hack();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
97 static gint open_output ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
98 static void buffer_reset (buffer_t *buf, config_t *cfg);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
99 static void *buffer_thread_f (void *arg);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
100 static void sync_output ();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
101
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
102 /* special XMMS symbols (dynamically looked up, see xfade_init) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
103 static gboolean *xmms_playlist_get_info_going = NULL; /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
104 static gboolean *xmms_is_quitting = NULL; /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
105 static gboolean (*input_stopped_for_restart)() = NULL; /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
106
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
107 void fini() __attribute__((destructor));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
108
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
109 /* local variables */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
110 static gint session_id;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
111 static gboolean realtime;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
112 static gboolean is_http;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
113
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
114 static gint64 streampos; /* position within current song (input bps) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
115 static gboolean playing;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
116 gboolean opened; /* TRUE between open_ and close_audio() */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
117 static gboolean paused; /* TRUE: no playback (but still filling buffer) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
118 static gboolean stopped; /* TRUE: stop buffer thread ASAP */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
119 static gboolean eop; /* TRUE: wait until buffer is empty then sync() */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
120
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
121 static plugin_config_t the_op_config = DEFAULT_OP_CONFIG;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
122 OutputPlugin *the_op = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
123 gint the_rate = 44100;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
124
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
125 static gboolean input_playing = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
126
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
127 gboolean output_opened = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
128 static gint output_flush_time = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
129 gint output_offset = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
130 static gint64 output_written = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
131 gint64 output_streampos = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
132
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
133 static gboolean finishing = FALSE; /* TRUE after fini() has been called */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
134
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
135 static gchar zero_4k[4096];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
136
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
137 #ifdef VOLUME_NORMALIZER
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
138 static quantaudio_t qa, last_qa;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
139 static gboolean have_qa = FALSE, have_last_qa = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
140 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
141
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
142
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
143 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
144 * Available fade configs:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
145 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
146 * fc_start: First song, only in_len and in_level are used
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
147 * fc_xfade: Automatic crossfade at end of song
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
148 * fc_album: Like xfade but for consecutive songs of the same album
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
149 * fc_manual: Manual crossfade (triggered by Next or Prev)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
150 * fc_stop: Last song, only out_len and out_level are used
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
151 * fc_eop: Last song, only out_len and out_level are used
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
152 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
153 * NOTE: As of version 0.2 of xmms-crossfade,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
154 * only xfade and manual are implemented.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
155 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
156 * With version 0.2.3, fc_album has been added.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
157 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
158 * With 0.2.4, all configs are implemented:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
159 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
160 * Available parameters:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
161 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
162 * | start | xfade | manual | album | stop | eop
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
163 * ------------+-------+-------+--------+-------+------+------
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
164 * in_len | yes | yes | yes | no | no | no
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
165 * in_volume | yes | yes | yes | no | no | no
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
166 * offset | no | yes | yes | no | +yes | +yes
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
167 * out_len | no | yes | yes | no | yes | yes
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
168 * out_volume | no | yes | yes | no | yes | yes
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
169 * flush (*) | no | no | yes | no | yes | no
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
170 * ------------+-------+-------+--------+-------+------+------
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
171 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
172 * Parameters marked with (*) are not configureable by the user
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
173 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
174 * The offset parameters for 'stop' and 'eop' is used to store the
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
175 * length of the additional silence to be added. It may be >= 0 only.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
176 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
177 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
178
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
179 static struct timeval last_close;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
180 static struct timeval last_write;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
181
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
182 static gchar *last_filename = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
183
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
184 static format_t in_format;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
185 static format_t out_format;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
186
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
187 static buffer_t the_buffer;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
188 buffer_t *buffer = &the_buffer;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
189
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
190 GStaticMutex buffer_mutex = G_STATIC_MUTEX_INIT;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
191 static GThread *buffer_thread;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
192
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
193 static effect_context_t effect_context;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
194 static convert_context_t convert_context;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
195 static rate_context_t rate_context;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
196 static volume_context_t volume_context;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
197
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
198 static config_t the_config;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
199 config_t *config = &the_config;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
200 config_t config_default = CONFIG_DEFAULT;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
201
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
202 static fade_config_t *fade_config = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
203
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
204
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
205 /* this is the entry point for XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
206 OutputPlugin *get_oplugin_info()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
207 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
208 return &xfade_op;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
209 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
210
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
211 OutputPlugin *get_crossfade_oplugin_info()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
212 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
213 return &xfade_op;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
214 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
215
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
216 static gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
217 effect_list_f(gconstpointer a, gconstpointer b)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
218 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
219 EffectPlugin *ep = (EffectPlugin *)a;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
220 gchar *name = (gchar *)b;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
221
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
222 return strcmp(g_basename(ep->filename), name);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
223 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
224
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
225 static gboolean
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
226 open_output_f(gpointer data)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
227 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
228 DEBUG(("[crossfade] open_output_f: pid=%d\n", getpid()));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
229 open_output();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
230 return FALSE; /* FALSE = 'do not call me again' */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
231 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
232
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
233 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
234 xfade_realize_ep_config()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
235 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
236 GList *list, *element;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
237 EffectPlugin *ep = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
238
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
239 /* find effect plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
240 if(config->ep_enable && config->ep_name && (list = get_effect_list())) /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
241 if((element = g_list_find_custom(list, config->ep_name, effect_list_f)))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
242 ep = element->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
243
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
244 effect_set_plugin(&effect_context, ep);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
245 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
246
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
247 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
248 xfade_realize_config() /* also called by xfade_init() */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
249 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
250 /* realize effect plugin config */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
251 xfade_realize_ep_config();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
252
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
253 #ifdef VOLUME_NORMALIZER
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
254 /* update volume normalizer target rms */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
255 volume_set_target_rms(&volume_context, config->volnorm_target);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
256 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
257
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
258 /* 0.3.0: keep device opened */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
259 if(config->output_keep_opened && !output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
260 DEBUG(("[crossfade] realize_config: keeping output opened...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
261
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
262 /* HACK: avoid rate converter complaing about illegal input rate */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
263 /* if(!rate_context.valid || !rate_context.in_rate)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
264 rate_config(&rate_context, out_format.rate, out_format.rate); */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
265
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
266 /* 0.3.1: HACK: this will make sure that we start playing silence after startup */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
267 gettimeofday(&last_close, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
268
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
269 /* 0.3.1: HACK: Somehow, if we open output here at XMMS startup, there
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
270 will be leftover filedescriptors later when closing output again.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
271 Opening output in a timeout function seems to work around this... */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
272 DEBUG(("[crossfade] realize_config: adding timeout (pid=%d)\n", getpid()));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
273 g_timeout_add(0, open_output_f, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
274 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
275 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
276
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
277 static gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
278 output_list_f(gconstpointer a, gconstpointer b)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
279 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
280 OutputPlugin *op = (OutputPlugin *)a;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
281 gchar *name = (gchar *)b;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
282
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
283 return strcmp(g_basename(op->filename), name);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
284 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
285
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
286 static OutputPlugin *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
287 find_output()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
288 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
289 GList *list, *element;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
290 OutputPlugin *op = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
291
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
292 /* find output plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
293 if(config->op_name && (list = get_output_list())) /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
294 if((element = g_list_find_custom(list, config->op_name, output_list_f)))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
295 op = element->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
296
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
297 if(op == &xfade_op) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
298 DEBUG(("[crossfade] find_output: can't use myself as output plugin!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
299 op = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
300 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
301 else if(!op) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
302 DEBUG(("[crossfade] find_output: could not find output plugin \"%s\"\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
303 config->op_name ? config->op_name : "#NULL#"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
304 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
305 else /* ok, we have a plugin. last, get its compatibility options */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
306 xfade_load_plugin_config(config->op_config_string, config->op_name,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
307 &the_op_config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
308
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
309 return op;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
310 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
311
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
312 static gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
313 open_output()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
314 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
315 /* sanity check */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
316 if(output_opened)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
317 DEBUG(("[crossfade] open_output: WARNING: output_opened=TRUE!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
318
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
319 /* reset output_* */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
320 output_opened = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
321 output_flush_time = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
322 output_offset = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
323 output_written = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
324 output_streampos = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
325
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
326 /* get output plugin (this will also init the_op_config) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
327 if(!(the_op = find_output())) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
328 DEBUG(("[crossfade] open_output: could not find any output!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
329 return -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
330 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
331
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
332 /* print output plugin info */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
333 DEBUG(("[crossfade] open_output: using \"%s\" for output",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
334 the_op->description ? the_op->description : "#NULL#"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
335
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
336 if(realtime)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
337 DEBUG((" (RT)"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
338
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
339 if(the_op_config.throttle_enable)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
340 DEBUG((realtime
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
341 ? " (throttled (disabled with RT))"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
342 : " (throttled)"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
343
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
344 if(the_op_config.max_write_enable)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
345 DEBUG((" (max_write=%d)", the_op_config.max_write_len));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
346
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
347 DEBUG(("\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
348
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
349 /* setup sample rate (note that OUTPUT_RATE is #defined as the_rate) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
350 the_rate = config->output_rate;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
351
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
352 /* setup out_format. use host byte order for easy math */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
353 setup_format(FMT_S16_NE, OUTPUT_RATE, OUTPUT_NCH, &out_format);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
354
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
355 /* force re-config of rate converter */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
356 if(in_format.rate == 0) /* this happens with keep_output_opened */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
357 rate_config(&rate_context, out_format.rate, out_format.rate, config->output_quality);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
358 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
359 rate_config(&rate_context, in_format.rate, out_format.rate, config->output_quality);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
360
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
361 /* open plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
362 if(!the_op->open_audio(out_format.fmt, out_format.rate, out_format.nch)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
363 DEBUG(("[crossfade] open_output: open_audio() failed!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
364 the_op = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
365 return -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
366 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
367
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
368 /* clear buffer struct */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
369 memset(buffer, 0, sizeof(*buffer));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
370
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
371 /* calculate buffer size */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
372 buffer->mix_size = MS2B(xfade_mix_size_ms(config)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
373 buffer->sync_size = MS2B(config->sync_size_ms) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
374 buffer->preload_size = MS2B(config->preload_size_ms) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
375
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
376 buffer->size = (buffer->mix_size + /* mixing area */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
377 buffer->sync_size + /* additional sync */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
378 buffer->preload_size); /* preload */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
379
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
380 DEBUG(("[crossfade] open_output: buffer: size=%d (%d+%d+%d=%d ms) (%d Hz)\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
381 buffer->size,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
382 B2MS(buffer->mix_size),
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
383 B2MS(buffer->preload_size),
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
384 B2MS(buffer->sync_size),
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
385 B2MS(buffer->size),
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
386 the_rate));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
387
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
388 /* allocate buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
389 if(!(buffer->data = g_malloc0(buffer->size))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
390 DEBUG(("[crossfade] open_output: error allocating buffer!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
391 the_op->close_audio();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
392 the_op = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
393 return -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
394 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
395
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
396 /* reset buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
397 buffer_reset(buffer, config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
398
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
399 /* make sure stopped is TRUE -- otherwise the buffer thread would
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
400 * stop again immediatelly after it has been started. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
401 stopped = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
402
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
403 /* create and run buffer thread */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
404 buffer_thread = g_thread_create((GThreadFunc)buffer_thread_f, NULL, FALSE, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
405 if (buffer_thread == NULL) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
406 PERROR("[crossfade] open_output: g_thread_create()");
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
407 g_free(buffer->data);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
408 the_op->close_audio();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
409 the_op = NULL;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
410 return -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
411 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
412
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
413 /* start updating monitor */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
414 xfade_start_monitor();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
415
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
416 /* done */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
417 output_opened = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
418 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
419 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
420
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
421 static void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
422 xfade_init()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
423 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
424 /* load config */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
425 memset(config, 0, sizeof(*config));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
426 *config = config_default;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
427 xfade_load_config();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
428
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
429 /* set default strings if there is no existing config */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
430 if(!config->op_config_string)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
431 config->op_config_string = g_strdup(DEFAULT_OP_CONFIG_STRING);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
432 if(!config->op_name)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
433 config->op_name = g_strdup(DEFAULT_OP_NAME);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
434
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
435 /* check for realtime priority, it needs some special attention */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
436 realtime = xmms_check_realtime_priority();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
437
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
438 /* show monitor win if enabled in config */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
439 xfade_check_monitor_win();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
440
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
441 /* init contexts */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
442 effect_init(&effect_context, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
443 convert_init(&convert_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
444 rate_init(&rate_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
445 volume_init(&volume_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
446
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
447 /* reset */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
448 stopped = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
449
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
450 /* find current output plugin early so that volume control works
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
451 * even if playback has not started yet. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
452 if(!(the_op = find_output()))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
453 DEBUG(("[crossfade] init: could not find any output!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
454
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
455 /* get xmms controlsocket session id */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
456 session_id = ctrlsocket_get_session_id();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
457
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
458 /* load any dynamic linked symbols */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
459 load_symbols();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
460
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
461 /* HACK: make sure we are at the beginning of XMMS' output plugin list */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
462 output_list_hack();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
463
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
464 /* realize config -- will also setup the pre-mixing effect plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
465 xfade_realize_config();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
466 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
467
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
468 static void load_symbols()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
469 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
470 #ifdef HAVE_DLFCN_H
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
471 void *handle;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
472 char *error;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
473
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
474 /* open ourselves (that is, the XMMS binary) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
475 handle = dlopen(NULL, RTLD_NOW);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
476 if(!handle) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
477 DEBUG(("[crossfade] init: dlopen(NULL) failed!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
478 return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
479 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
480
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
481 /* check for XMMS patches */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
482 DEBUG(("[crossfade] load_symbols: input_stopped_for_restart:"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
483 input_stopped_for_restart = dlsym(handle, "input_stopped_for_restart");
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
484 DEBUG((!(error = dlerror()) ? " found\n" : " not found\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
485
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
486 DEBUG(("[crossfade] load_symbols: playlist_get_info_going:"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
487 xmms_playlist_get_info_going = dlsym(handle, "playlist_get_info_going");
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
488 DEBUG((!(error = dlerror()) ? " found\n" : " not found\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
489
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
490 DEBUG(("[crossfade] load_symbols: is_quitting:"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
491 xmms_is_quitting = dlsym(handle, "is_quitting");
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
492 DEBUG((!(error = dlerror()) ? " found\n" : " not found\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
493
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
494 dlclose(handle);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
495 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
496 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
497
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
498 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
499 HACK: Try to move ourselves to the beginning of XMMS output plugin list,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
500 so that we will be freed first when XMMS is quitting. This way, we
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
501 avoid the segfault when using ALSA as the output plugin.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
502 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
503 static void output_list_hack()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
504 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
505 GList *output_list = get_output_list();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
506
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
507 int i0 = g_list_index(output_list, &xfade_op), i1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
508
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
509 GList *first = g_list_first(output_list);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
510 GList *xfade = g_list_find (output_list, &xfade_op);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
511 xfade->data = first->data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
512 first->data = &xfade_op;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
513
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
514 i1 = g_list_index(output_list, &xfade_op);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
515 if (i0 != i1)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
516 DEBUG(("[crossfade] output_list_hack: crossfade moved from index %d to %d\n", i0, i1));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
517 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
518
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
519 void fini()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
520 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
521 DEBUG(("[crossfade]\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
522 DEBUG(("[crossfade] fini: cleanup:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
523
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
524 /* wait for buffer_thread to stop */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
525 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
526
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
527 /* reset last_close so that the buffer thread will
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
528 * not unnecessarily wait for a timeout. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
529 memset(&last_close, 0, sizeof(last_close));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
530
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
531 /* HACK: tell buffer thread not to close output by itself */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
532 finishing = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
533 paused = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
534
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
535 /* wait for buffer thread to clean up and terminate */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
536 DEBUG(("[crossfade] fini: cleanup: waiting for buffer thread...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
537 while(output_opened && finishing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
538 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
539 xmms_usleep(10000);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
540 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
541 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
542 DEBUG(("[crossfade] fini: cleanup: waiting for buffer thread... done\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
543
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
544 /* HACK: 0.3.5: close output plugin from THIS thread */
268
1368faba73c9 [svn] We shouldn't have to close the output plugin from here. I don't know why
nenolod
parents: 267
diff changeset
545 #if 0
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
546 if(output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
547 DEBUG(("[crossfade] fini: cleanup: closing audio...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
548 if(the_op->close_audio) the_op->close_audio();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
549 DEBUG(("[crossfade] fini: cleanup: closing audio... done\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
550 g_free(buffer->data);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
551 output_opened = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
552 }
268
1368faba73c9 [svn] We shouldn't have to close the output plugin from here. I don't know why
nenolod
parents: 267
diff changeset
553 #endif
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
554 DEBUG(("[crossfade] fini: cleanup: done\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
555
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
556 g_static_mutex_unlock (&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
557
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
558 /* free contexts */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
559 volume_free(&volume_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
560 rate_free(&rate_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
561 convert_free(&convert_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
562 effect_free(&effect_context);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
563
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
564 /* save configuration (required only for mixer_vol_*) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
565 xfade_save_config();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
566
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
567 /* free resources */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
568 if(config->op_name) g_free(config->op_name);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
569 xfade_free_config();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
570 if(last_filename) g_free(last_filename);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
571
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
572 DEBUG(("[crossfade] fini: done.\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
573 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
574
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
575 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
576 xfade_get_volume(int *l, int *r)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
577 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
578 if(config->mixer_software) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
579 if(config->mixer_reverse) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
580 *l = config->mixer_vol_right;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
581 *r = config->mixer_vol_left;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
582 } else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
583 *l = config->mixer_vol_left;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
584 *r = config->mixer_vol_right;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
585 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
586 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
587 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
588 if(the_op && the_op->get_volume) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
589 if(config->mixer_reverse)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
590 the_op->get_volume(r, l);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
591 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
592 the_op->get_volume(l, r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
593 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
594 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
595 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
596
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
597 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
598 xfade_set_volume(int l, int r)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
599 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
600 if(!config->enable_mixer) return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
601 if(config->mixer_software) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
602 if(config->mixer_reverse) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
603 config->mixer_vol_right = l;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
604 config->mixer_vol_left = r;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
605 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
606 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
607 config->mixer_vol_right = r;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
608 config->mixer_vol_left = l;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
609 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
610 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
611 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
612 if(the_op && the_op->set_volume) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
613 if(config->mixer_reverse)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
614 the_op->set_volume(r, l);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
615 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
616 the_op->set_volume(l, r);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
617 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
618 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
619 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
620
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
621 /*** buffer stuff ***********************************************************/
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
622
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
623 static void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
624 buffer_mfg_reset(buffer_t *buf, config_t *cfg)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
625 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
626 buf->mix = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
627 buf->fade = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
628 buf->gap = (cfg->gap_lead_enable ? MS2B(cfg->gap_lead_len_ms) & -4 : 0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
629 buf->gap_len = buf->gap;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
630 buf->gap_level = cfg->gap_lead_level;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
631 buf->gap_killed = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
632 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
633
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
634 static void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
635 buffer_reset(buffer_t *buf, config_t *cfg)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
636 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
637 buffer_mfg_reset(buf, cfg);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
638
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
639 buf->rd_index = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
640 buf->used = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
641 buf->preload = buf->preload_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
642
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
643 buf->silence = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
644 buf->silence_len = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
645 buf->reopen = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
646 buf->pause = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
647 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
648
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
649 /****************************************************************************/
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
650
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
651 static void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
652 xfade_apply_fade_config(fade_config_t *fc)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
653 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
654 gint avail, out_len, in_len, offset, skip;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
655 gint index, length, fade, n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
656 gfloat out_scale, in_scale;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
657 gboolean out_len_clipped = FALSE, offset_clipped = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
658
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
659 /* Overwrites mix and fade; may add silence */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
660
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
661 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
662 * Example 1: offset < 0 --> mix streams together
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
663 * Example 2: offset > 0 --> insert pause between streams
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
664 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
665 * |----- out_len -----| * |out_len|
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
666 * | | * | |
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
667 * ~~~~~-_ /T~~~~~~~T~~ * ~~~~~\ | /T~~
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
668 * ~-_ / | | * \ | / |
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
669 * ~-_/ | | * \ | / |
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
670 * /~-_| | * \ | / |
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
671 * / T-_ | * \ | / |
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
672 * / | ~-_ | * \ | / |
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
673 * _________/______|_____~-|__ * ___________\__________/______|__
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
674 * |in_len| | * | |in_len|
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
675 * |<-- offset ---| * |offset-->|
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
676 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
677 * a) avail: max(0, used - preload)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
678 * b) out_len: 0 .. avail
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
679 * c) in_len: 0 .. #
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
680 * d) offset: -avail .. buffer->mix_size - out_size
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
681 * e) skip: min(used, preload)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
682 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
683 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
684
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
685 out_scale = 1.0f - (gfloat)xfade_cfg_fadeout_volume(fc) / 100.0f;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
686 in_scale = 1.0f - (gfloat)xfade_cfg_fadein_volume (fc) / 100.0f;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
687
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
688 /* rules (see above) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
689 /* a */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
690 avail = buffer->used - buffer->preload_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
691 if(avail < 0) avail = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
692
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
693 /* b */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
694 out_len = MS2B(xfade_cfg_fadeout_len(fc)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
695 if(out_len < 0) out_len = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
696 if(out_len > avail) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
697 DEBUG(("[crossfade] apply_fade_config: WARNING: clipping out_len (%d -> %d)!\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
698 B2MS(out_len), B2MS(avail)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
699 out_len = avail;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
700 out_len_clipped = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
701 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
702
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
703 /* c */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
704 in_len = MS2B(xfade_cfg_fadein_len(fc)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
705 if(in_len < 0) in_len = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
706
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
707 /* d */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
708 offset = MS2B(xfade_cfg_offset(fc)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
709 if(offset < -avail) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
710 DEBUG(("[crossfade] apply_fade_config: WARNING: clipping offset (%d -> %d)!\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
711 B2MS(offset), -B2MS(avail)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
712 offset = -avail;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
713 offset_clipped = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
714 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
715 if(offset > (buffer->mix_size - out_len))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
716 offset = buffer->mix_size - out_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
717
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
718 /* e */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
719 skip = buffer->preload_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
720 if(skip > buffer->used) skip = buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
721
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
722 /* cut off rest of stream (decreases latency on manual songchange) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
723 if(fc->flush) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
724 gint cutoff = avail - MAX(out_len, -offset); /* MAX() -> glib.h */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
725 if(cutoff > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
726 DEBUG(("[crossfade] apply_fade_config: %d ms flushed\n", B2MS(cutoff)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
727 buffer->used -= cutoff;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
728 avail -= cutoff;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
729 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
730
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
731 /* make sure there is no pending silence */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
732 buffer->silence = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
733 buffer->silence_len = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
734 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
735
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
736 /* begin modifying buffer at index */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
737 index = (buffer->rd_index + buffer->used - out_len) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
738
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
739 /* fade out (modifies buffer directly) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
740 fade = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
741 length = out_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
742 while(length > 0) {
267
38ee4e7f91e6 [svn] revert changes -- broke the plugin :/
nenolod
parents: 266
diff changeset
743 gint16 *p = buffer->data + index;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
744 gint blen = buffer->size - index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
745 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
746
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
747 for(n = blen/4; n > 0; n--) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
748 gfloat factor = 1.0f - (((gfloat)fade / out_len) * out_scale);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
749 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
750 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
751 fade += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
752 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
753
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
754 index = (index + blen) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
755 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
756 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
757
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
758 /* Initialize fadein. Note that the actual fading / mixing will be done
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
759 * on-the-fly when audio data is received by xfade_write_audio() */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
760
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
761 /* start fading in */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
762 if(in_len > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
763 buffer->fade = in_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
764 buffer->fade_len = in_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
765 buffer->fade_scale = in_scale;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
766 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
767 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
768 buffer->fade = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
769
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
770 /* start mixing */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
771 if(offset < 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
772 length = -offset;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
773 buffer->mix = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
774 buffer->used -= length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
775 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
776 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
777 buffer->mix = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
778
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
779 /* start silence if applicable (will be applied in buffer_thread_f) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
780 if(offset > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
781 if((buffer->silence > 0) || (buffer->silence_len > 0))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
782 DEBUG(("[crossfade] apply_config: WARNING: silence in progress (%d/%d ms)\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
783 B2MS(buffer->silence), B2MS(buffer->silence_len)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
784
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
785 buffer->silence = buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
786 buffer->silence_len = offset;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
787 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
788
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
789 /* done */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
790 DEBUG(("[crossfade] apply_fade_config: avail=%d out=%d in=%d offset=%d skip=%d\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
791 B2MS(avail), B2MS(out_len), B2MS(in_len), B2MS(offset), B2MS(skip)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
792 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
793
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
794 static gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
795 extract_track(gchar *name)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
796 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
797 /* Remove all but numbers.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
798 * Will not work if a filename has number in the title, like "track-03-U2.mp3"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
799 * Ideally, should look into id3 track entry and fallback to filename
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
800 * */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
801
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
802 gchar temp[8];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
803 int t = 0 ;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
804
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
805 memset(temp,0,sizeof(temp));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
806 while(*name != '\0' && t < sizeof(temp)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
807 if(strcmp(name,"mp3") == 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
808 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
809 if(isdigit(*name))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
810 temp[t++] = *name;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
811 name++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
812 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
813 return atoi(temp);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
814 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
815
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
816 static gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
817 album_match(gchar *old, gchar *new)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
818 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
819 gchar *old_dir, *new_dir;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
820 gboolean same_dir;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
821 gint old_track = 0, new_track = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
822
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
823 if(!old || !new) return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
824
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
825 old_dir = g_dirname(old);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
826 new_dir = g_dirname(new);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
827 same_dir = !strcmp(old_dir, new_dir);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
828 g_free(old_dir);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
829 g_free(new_dir);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
830
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
831 if(!same_dir) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
832 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
833 "no match (different dirs)\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
834 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
835 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
836
262
5410de731c3c [svn] Remove last of the internal OSS support and default to ALSA. Squashed a few warnings but it is still messy.
chainsaw
parents: 261
diff changeset
837 old_track = extract_track(g_path_get_basename(old));
5410de731c3c [svn] Remove last of the internal OSS support and default to ALSA. Squashed a few warnings but it is still messy.
chainsaw
parents: 261
diff changeset
838 new_track = extract_track(g_path_get_basename(new));
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
839
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
840 if(new_track <= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
841 DEBUG(("[crossfade] album_match: can't parse track number:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
842 DEBUG(("[crossfade] album_match: ... \"%s\"\n", g_basename(new)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
843 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
844 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
845
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
846 if((old_track < 0) || (old_track+1 != new_track)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
847 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
848 "no match (same dir, but non-successive (%d, %d))\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
849 old_track, new_track));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
850 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
851 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
852
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
853 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
854 "match detected (same dir, successive tracks (%d, %d))\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
855 old_track, new_track));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
856
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
857 return old_track;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
858 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
859
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
860 static gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
861 xfade_open_audio(AFormat fmt, int rate, int nch)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
862 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
863 gint pos;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
864 gchar *file;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
865
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
866 struct timeval tv;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
867 glong dt;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
868
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
869 DEBUG(("[crossfade]\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
870 DEBUG(("[crossfade] open_audio: XMMS-crossfade "VERSION"\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
871
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
872 #if 0
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
873 DEBUG(("[crossfade] open_audio: pid=%d\n", getpid()));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
874 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
875
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
876 /* sanity... don't do anything about it */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
877 if(opened)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
878 DEBUG(("[crossfade] open_audio: WARNING: already opened!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
879
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
880 /* get filename */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
881 #ifdef HAVE_PLAYLIST_GET_FILENAME
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
882 pos = get_playlist_position(); /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
883 file = playlist_get_filename(pos); /* XMMS */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
884 #else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
885 pos = xmms_remote_get_playlist_pos (session_id);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
886 file = xmms_remote_get_playlist_file(session_id, pos);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
887 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
888 DEBUG(("[crossfade] open_audio: bname=\"%s\"\n", g_basename(file)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
889
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
890 /* is this an automatic crossfade? */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
891 if(last_filename && (fade_config == &config->fc[FADE_CONFIG_XFADE])) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
892 /* check if next song is the same as the current one */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
893 if(config->no_xfade_if_same_file && !strcmp(last_filename, file)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
894 DEBUG(("[crossfade] open_audio: same file, disabling crossfade\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
895 fade_config = &config->fc[FADE_CONFIG_ALBUM];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
896 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
897
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
898 /* check if next song is the next song from the same album */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
899 else if(config->album_detection && album_match(last_filename, file)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
900 gboolean use_fc_album = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
901
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
902 if(xfade_cfg_gap_trail_enable(config)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
903 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
904 "trailing gap: length=%d/%d ms\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
905 B2MS(buffer->gap_killed), B2MS(buffer->gap_len)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
906
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
907 if(buffer->gap_killed < buffer->gap_len) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
908 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
909 "trailing gap: -> no silence, probably pre-faded\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
910 use_fc_album = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
911 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
912 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
913 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
914 "trailing gap: -> silence, sticking to XFADE\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
915 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
916 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
917 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
918 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
919 "trailing gap killer disabled\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
920 use_fc_album = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
921 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
922
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
923 if(use_fc_album) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
924 DEBUG(("[crossfade] album_match: "
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
925 "-> using FADE_CONFIG_ALBUM\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
926 fade_config = &config->fc[FADE_CONFIG_ALBUM];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
927 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
928 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
929 g_free(last_filename);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
930 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
931 last_filename = g_strdup(file);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
932
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
933 #if 0
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
934 /* FIXME: finish this */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
935 /* Check if this is a short song. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
936 if(fade_config == &config->fc[FADE_CONFIG_XFADE]) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
937 DEBUG(("*** XFADE:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
938 int current_length = playlist_get_current_length();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
939 DEBUG(("*** length=%d\n", current_length));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
940 if (current_length < 30*1000)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
941 fade_config = &config->fc[FADE_CONFIG_ALBUM];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
942 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
943 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
944
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
945 #ifdef VOLUME_NORMALIZER
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
946 /* turn off volume normalizing per default, until we get a target RMS for this song */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
947 volume_set_active(&volume_context, FALSE);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
948
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
949 /* thomas: add support for quantaudio per-song mixing info */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
950 if(config->volnorm_use_qa) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
951 /* remember timing info from last song */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
952 last_qa = qa;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
953 have_last_qa = have_qa;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
954
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
955 /* try to read quantaudio comment from ID3v1 tag */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
956 have_qa = get_timing_comment(file, &qa);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
957 if(have_qa) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
958 DEBUG(("[crossfade] open_audio: quantaudio comment found:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
959 DEBUG(("[crossfade] open_audio: ... RMS=%d, mix_in=%.2f, mix_out=%.2f, length=%.2f\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
960 qa.RMS, qa.mix_in, qa.mix_out, qa.length));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
961 volume_set_song_rms(&volume_context, qa.RMS);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
962 volume_set_active (&volume_context, TRUE);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
963 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
964 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
965 DEBUG(("[crossfade] open_audio: no quantaudio comment found\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
966
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
967 #if 0
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
968 /* configure fade_config with fadeout from last song and fadein from new song */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
969 if(fade_config) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
970 config->fc[FADE_CONFIG_TIMING].out_enable = fade_config->out_enable;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
971 config->fc[FADE_CONFIG_TIMING].out_volume = fade_config->out_volume;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
972 config->fc[FADE_CONFIG_TIMING].out_len_ms = fade_config->out_len_ms;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
973 config->fc[FADE_CONFIG_TIMING].ofs_custom_ms = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
974 config->fc[FADE_CONFIG_TIMING].in_enable = fade_config->in_enable;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
975 config->fc[FADE_CONFIG_TIMING].in_volume = fade_config->in_volume;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
976 config->fc[FADE_CONFIG_TIMING].in_len_ms = fade_config->in_len_ms;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
977
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
978 if(have_last_qa && ((fade_config->config == FADE_CONFIG_XFADE) ||
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
979 (fade_config->config == FADE_CONFIG_ALBUM))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
980 fade_config = &config->fc[FADE_CONFIG_TIMING];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
981 fade_config->out_enable = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
982 fade_config->out_volume = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
983 fade_config->out_len_ms = (gint)((last_qa.length - last_qa.mix_out) * 1000);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
984 fade_config->ofs_custom_ms = - fade_config->out_len_ms; /* FIXME: */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
985 DEBUG(("[crossfade] open_audio: CONFIG_TIMING: using last song's fadeout parameter\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
986 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
987
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
988 if(have_qa && ((fade_config->config == FADE_CONFIG_XFADE) ||
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
989 (fade_config->config == FADE_CONFIG_ALBUM) ||
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
990 (fade_config->config == FADE_CONFIG_MANUAL))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
991 fade_config = &config->fc[FADE_CONFIG_TIMING];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
992 fade_config->in_enable = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
993 fade_config->in_volume = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
994 fade_config->in_len_ms = (gint)(qa.mix_in * 1000);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
995 DEBUG(("[crossfade] open_audio: CONFIG_TIMING: using new song's fadein parameter\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
996 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
997 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
998 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
999 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1000 else have_qa = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1001 /* thomas: end */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1002
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1003 if(volume_context.active && config->volnorm_enable)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1004 DEBUG(("[crossfade] open_audio: volume normalizer: factor=%.3f\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1005 volume_context.factor));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1006 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1007
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1008 /* check for HTTP streaming */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1009 if(config->enable_http_workaround && (0 == strncasecmp(file, "http://", 7))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1010 DEBUG(("[crossfade] open_audio: HTTP underrun workaround enabled.\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1011 is_http = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1012 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1013 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1014 is_http = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1015
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1016 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1017 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1018
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1019 /* reset writer timeout */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1020 gettimeofday(&last_write, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1021
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1022 /* calculate time since last close() (don't care about overflows at 24h) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1023 if(output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1024 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1025 dt = (tv.tv_sec - last_close.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1026 + (tv.tv_usec - last_close.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1027 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1028 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1029 dt = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1030
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1031 DEBUG(("[crossfade] open_audio: fmt=%s rate=%d nch=%d dt=%ld ms\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1032 format_name(fmt), rate, nch, dt));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1033
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1034 /* check format */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1035 if(setup_format(fmt, rate, nch, &in_format) < 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1036 DEBUG(("[crossfade] open_audio: format not supported!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1037 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1038 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1039
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1040 /* (re)open the device if necessary */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1041 if(!output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1042 if(open_output()) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1043 DEBUG(("[crossfade] open_audio: error opening/configuring output!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1044 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1045 return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1046 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1047 fade_config = &config->fc[FADE_CONFIG_START];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1048 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1049
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1050 /* reset */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1051 streampos = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1052 playing = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1053 opened = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1054 paused = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1055
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1056 /* reset mix/fade/gap */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1057 buffer_mfg_reset(buffer, config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1058
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1059 /* enable gap killer / zero crossing only for automatic/album songchange */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1060 switch(fade_config->config) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1061 case FADE_CONFIG_XFADE:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1062 case FADE_CONFIG_ALBUM:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1063 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1064 default:;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1065 buffer->gap = GAP_SKIPPING_DONE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1066 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1067
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1068 /* restart realtime throttling */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1069 output_written = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1070
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1071 /* start mixing */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1072 switch(fade_config ? fade_config->type : -1) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1073 case FADE_TYPE_FLUSH:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1074 DEBUG(("[crossfade] open_audio: FLUSH:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1075
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1076 /* flush output plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1077 the_op->flush(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1078 output_streampos = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1079
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1080 /* flush buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1081 buffer_reset(buffer, config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1082
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1083 /* apply fade config (pause/fadein after flush) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1084 xfade_apply_fade_config(fade_config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1085
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1086 /* also repopen device (if configured so in the plugin compat. options) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1087 if(the_op_config.force_reopen) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1088 buffer->reopen = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1089 buffer->reopen_sync = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1090 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1091 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1092
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1093 case FADE_TYPE_REOPEN:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1094 DEBUG(("[crossfade] open_audio: REOPEN:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1095
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1096 /* flush buffer if applicable */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1097 if(fade_config->flush)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1098 buffer_reset(buffer, config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1099
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1100 if(buffer->reopen >= 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1101 DEBUG(("[crossfade] open_audio: REOPEN: WARNING: reopen in progress (%d ms)\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1102 B2MS(buffer->reopen)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1103
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1104 /* start reopen countdown (will be executed in buffer_thread_f) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1105 buffer->reopen = buffer->used; /* may be 0 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1106 buffer->reopen_sync = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1107 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1108
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1109 case FADE_TYPE_NONE:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1110 case FADE_TYPE_PAUSE:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1111 case FADE_TYPE_SIMPLE_XF:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1112 case FADE_TYPE_ADVANCED_XF:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1113 case FADE_TYPE_FADEIN:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1114 case FADE_TYPE_FADEOUT:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1115 DEBUG(("[crossfade] open_audio: XFADE:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1116
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1117 /* apply fade config (do fadeout, init mix/fade/gap, add silence) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1118 xfade_apply_fade_config(fade_config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1119
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1120 /* set reopen countdown. after buffer_thread_f has written
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1121 * buffer->reopen bytes, it will close/reopen the output plugin. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1122 if(the_op_config.force_reopen && !(fade_config->config == FADE_CONFIG_START)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1123 if(buffer->reopen >= 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1124 DEBUG(("[crossfade] open_audio: XFADE: WARNING: reopen in progress (%d ms)\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1125 B2MS(buffer->reopen)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1126 buffer->reopen = buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1127 buffer->reopen_sync = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1128 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1129 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1130 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1131
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1132 /* calculate offset of the output plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1133 output_offset = the_op->written_time() + B2MS(buffer->used) + B2MS(buffer->silence_len);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1134
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1135 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1136 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1137
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1138 /* done */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1139 return 1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1140 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1141
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1142 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1143 xfade_write_audio(void *ptr, int length)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1144 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1145 gint free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1146 gint ofs = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1147 format_t format;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1148
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1149 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1150 DEBUG(("[crossfade] write_audio: ptr=0x%08lx, length=%d\n", (long)ptr, length));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1151 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1152
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1153 /* sanity */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1154 if(length <= 0) return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1155 if(length & 3) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1156 DEBUG(("[crossfade] write_audio: truncating %d bytes!\n", length & 3));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1157 length &= -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1158 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1159
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1160 /* update input accumulator (using input format size) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1161 streampos += length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1162
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1163 /* apply pre-mixing effect (NOTE: format might change!) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1164 format_copy(&format, &in_format);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1165 length = effect_flow(&effect_context, (gpointer*)&ptr, length, &format, TRUE);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1166
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1167 /* convert sample format (signed-16bit-ne 44100hz stereo) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1168 length = convert_flow(&convert_context, (gpointer*)&ptr, length, &format);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1169
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1170 /* convert rate */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1171 if(!rate_context.valid || (rate_context.in_rate != format.rate))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1172 rate_config(&rate_context, format.rate, out_format.rate, config->output_quality);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1173
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1174 length = rate_flow(&rate_context, (gpointer*)&ptr, length);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1175
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1176 #ifdef VOLUME_NORMALIZER
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1177 /* normalize volume */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1178 if(config->volnorm_enable)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1179 volume_flow(&volume_context, (gpointer*)&ptr, length);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1180 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1181
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1182 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1183 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1184
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1185 /* check if device has been closed, reopen if necessary */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1186 if(!output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1187 if(open_output()) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1188 DEBUG(("[crossfade] write_audio: reopening failed!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1189 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1190 return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1191 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1192 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1193
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1194 /* reset timeout */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1195 gettimeofday(&last_write, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1196
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1197 /* calculate free buffer space, check for overflow (should never happen :) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1198 free = buffer->size - buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1199 if(length > free) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1200 DEBUG(("[crossfade] write_audio: %d bytes truncated!\n", length-free));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1201 length = free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1202 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1203
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1204 /* kill leading gap */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1205 if((length > 0) && (buffer->gap > 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1206 gint blen = MIN(length, buffer->gap);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1207 gint16 *p = ptr;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1208 gint index = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1209
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1210 gint16 left, right;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1211 while(index < blen) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1212 left = *p++, right = *p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1213 if(ABS(left) >= buffer->gap_level) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1214 if(ABS(right) >= buffer->gap_level) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1215 index += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1216 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1217
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1218 buffer->gap -= index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1219 length -= index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1220 ptr += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1221
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1222 if((index < blen) || (buffer->gap <= 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1223 buffer->gap_killed = buffer->gap_len - buffer->gap;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1224 buffer->gap = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1225
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1226 DEBUG(("[crossfade] write_audio: leading gap size: %d/%d ms\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1227 B2MS(buffer->gap_killed), B2MS(buffer->gap_len)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1228
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1229 /* fix streampos */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1230 streampos -= (gint64)buffer->gap_killed * in_format.bps / out_format.bps;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1231 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1232 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1233
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1234 /* start skipping to next crossing (if enabled) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1235 if(buffer->gap == 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1236 if(config->gap_crossing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1237 buffer->gap = GAP_SKIPPING_POSITIVE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1238 buffer->gap_skipped = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1239 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1240 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1241 buffer->gap = GAP_SKIPPING_DONE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1242 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1243
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1244 /* skip until next zero crossing (pos -> neg) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1245 if((length > 0) && (buffer->gap == GAP_SKIPPING_POSITIVE)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1246 gint16 *p = ptr;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1247 gint index = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1248
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1249 gint16 left;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1250 while(index < length) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1251 left = *p++; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1252 if(left < 0) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1253 index += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1254 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1255
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1256 buffer->gap_skipped += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1257 length -= index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1258 ptr += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1260 if(index < length)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1261 buffer->gap = GAP_SKIPPING_NEGATIVE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1262 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1263
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1264 /* skip until next zero crossing (neg -> pos) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1265 if((length > 0) && (buffer->gap == GAP_SKIPPING_NEGATIVE)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1266 gint16 *p = ptr;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1267 gint index = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1268
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1269 gint16 left;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1270 while(index < length) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1271 left = *p++; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1272 if(left >= 0) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1273 index += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1274 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1275
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1276 buffer->gap_skipped += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1277 length -= index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1278 ptr += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1279
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1280 if(index < length) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1281 DEBUG(("[crossfade] write_audio: %d samples to next crossing\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1282 buffer->gap_skipped));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1283 buffer->gap = GAP_SKIPPING_DONE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1284 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1285 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1286
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1287 /* update preload. the buffer thread will not write any
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1288 * data to the device before preload is decreased below 1. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1289 if((length > 0) && (buffer->preload > 0))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1290 buffer->preload -= length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1291
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1292 /* fadein -- FIXME: is modifying the input/effect buffer safe? */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1293 if((length > 0) && (buffer->fade > 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1294 gint16 *p = ptr;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1295 gint blen = MIN(length, buffer->fade);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1296 gint n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1297
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1298 for(n = blen/4; n > 0; n--) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1299 gfloat factor = 1.0f - (((gfloat)buffer->fade / buffer->fade_len) * buffer->fade_scale);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1300 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1301 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1302 buffer->fade -= 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1303 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1304 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1305
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1306 /* mix */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1307 while((length > 0) && (buffer->mix > 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1308 gint wr_index = (buffer->rd_index + buffer->used) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1309 gint blen = buffer->size - wr_index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1310 gint16 *p1 = buffer->data + wr_index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1311 gint16 *p2 = ptr + ofs;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1312 gint n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1313
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1314 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1315 if(blen > buffer->mix) blen = buffer->mix;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1316
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1317 for(n = blen/2; n > 0; n--) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1318 gint out = (gint)*p1 + *p2++; /* add */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1319 if(out > 32767) /* clamp */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1320 *p1++ = 32767;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1321 else if(out < -32768)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1322 *p1++ = -32768;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1323 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1324 *p1++ = out;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1325 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1326
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1327 buffer->used += blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1328 buffer->mix -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1329 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1330 ofs += blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1331 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1332
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1333 /* normal write */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1334 while(length > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1335 gint wr_index = (buffer->rd_index + buffer->used) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1336 gint blen = buffer->size - wr_index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1337
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1338 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1339
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1340 memcpy(buffer->data + wr_index, ptr + ofs, blen);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1341
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1342 buffer->used += blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1343 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1344 ofs += blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1345 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1346
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1347 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1348 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1349 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1350 DEBUG(("[crossfade] write_audio: done.\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1351 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1352 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1353
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1354 /* sync_output: wait for output plugin to finish playback */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1355 /* is only called from within buffer_thread_f */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1356 static void sync_output()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1357 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1358 glong dt, total;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1359 gint opt, opt_last;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1360 struct timeval tv, tv_start, tv_last_change;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1361 gboolean was_closed = !opened;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1362
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1363 if(!the_op->buffer_playing || !the_op->buffer_playing()) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1364 DEBUG(("[crossfade] sync_output: nothing to do\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1365 return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1366 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1367
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1368 DEBUG(("[crossfade] sync_output: waiting for plugin...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1369
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1370 dt = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1371 opt_last = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1372 gettimeofday(&tv_start, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1373 gettimeofday(&tv_last_change, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1374
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1375 while((dt < SYNC_OUTPUT_TIMEOUT)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1376 && !stopped
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1377 && output_opened
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1378 && !(was_closed && opened)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1379 && the_op && the_op->buffer_playing()) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1380
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1381 /* use output_time() to check if the output plugin is still active */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1382 if(the_op->output_time) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1383 opt = the_op->output_time();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1384 if(opt != opt_last) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1385 /* output_time has changed */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1386 opt_last = opt;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1387 gettimeofday(&tv_last_change, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1388 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1389 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1390 /* calculate time since last change of the_op->output_time() */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1391 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1392 dt = (tv.tv_sec - tv_last_change.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1393 + (tv.tv_usec - tv_last_change.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1394 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1395 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1396
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1397 /* yield */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1398 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1399 xmms_usleep(10000);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1400 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1401 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1402
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1403 /* calculate total time we spent in here */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1404 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1405 total = (tv.tv_sec - tv_start.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1406 + (tv.tv_usec - tv_start.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1407
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1408 /* print some debug info */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1409 if(stopped)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1410 DEBUG(("[crossfade] sync_output: ... stopped\n"))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1411 else if(was_closed && opened)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1412 DEBUG(("[crossfade] sync_output: ... reopened\n"))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1413 else if(dt >= SYNC_OUTPUT_TIMEOUT)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1414 DEBUG(("[crossfade] sync_output: ... TIMEOUT! (%ld ms)\n", total))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1415 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1416 DEBUG(("[crossfade] sync_output: ... done (%ld ms)\n", total));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1417 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1418
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1419 void *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1420 buffer_thread_f(void *arg)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1421 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1422 gpointer data;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1423 gint sync;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1424 gint op_free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1425 gint length_bak, length, blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1426 glong timeout, dt;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1427 gboolean stopping;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1428
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1429 struct timeval tv;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1430 struct timeval mark;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1431
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1432 DEBUG(("[crossfade] buffer_thread_f: thread started (pid=%d)\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1433 (int)getpid()));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1434
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1435 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1436 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1437
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1438 while(!stopped) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1439 /* yield */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1440 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1441 DEBUG(("[crossfade] buffer_thread_f: yielding...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1442 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1443 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1444 xmms_usleep(10000);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1445 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1446
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1447 /* --------------------------------------------------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1448
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1449 stopping = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1450
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1451 /* V0.3.0: New timeout detection */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1452 if(!opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1453 gboolean current = bmp_playback_get_playing(); /* BEEP */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1454
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1455 /* also see fini() */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1456 if(last_close.tv_sec || last_close.tv_usec) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1457 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1458 timeout = (tv.tv_sec - last_close.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1459 + (tv.tv_usec - last_close.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1460 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1461 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1462 timeout = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1463
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1464 if(current != input_playing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1465 input_playing = current;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1466 if(current)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1467 DEBUG(("[crossfade] buffer_thread_f:"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1468 " input restarted after %ld ms\n", timeout))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1469 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1470 DEBUG(("[crossfade] buffer_thread_f:"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1471 " input stopped after + %ld ms\n", timeout));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1472 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1473
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1474 /* 0.3.0: HACK: output_keep_opened: play silence during prebuffering */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1475 if(input_playing && config->output_keep_opened && (buffer->used == 0)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1476 buffer->silence = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1477 buffer->silence_len = MS2B(100);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1478 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1479
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1480 /* FIXME: make timeout configureable */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1481 if(((timeout < 0) || (timeout >= 100)) && !input_playing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1482 if(playing)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1483 DEBUG(("[crossfade] buffer_thread_f: timeout:"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1484 " input did not restart after %ld ms (playing=%d)\n", timeout, playing));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1485 stopping = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1486 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1487 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1488
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1489 /* V0.2.4: Moved the timeout checks in front of the buffer_free() check
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1490 * below. Before, buffer_thread_f could (theoretically) loop
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1491 * endlessly if buffer_free() returned 0 all the time. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1492
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1493 /* calculate time since last write to the buffer (ignore overflows) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1494 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1495 timeout = (tv.tv_sec - last_write.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1496 + (tv.tv_usec - last_write.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1497
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1498 /* check for timeout/eop (note this is the only way out of this loop) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1499 if(stopping) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1500 if(playing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1501 DEBUG(("[crossfade] buffer_thread_f: timeout: manual stop\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1502
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1503 /* if CONFIG_STOP is of TYPE_NONE, immediatelly close the device... */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1504 if((config->fc[FADE_CONFIG_STOP].type == FADE_TYPE_NONE)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1505 && !config->output_keep_opened) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1506
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1507 /* special handling for pause */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1508 if(paused) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1509 DEBUG(("[crossfade] buffer_thread_f: timeout: paused, closing now...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1510 paused = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1511 if(config->output_keep_opened)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1512 the_op->pause(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1513 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1514 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1515 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1516 else if(buffer->pause >= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1517 DEBUG(("[crossfade] buffer_thread_f: timeout: cancelling pause countdown\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1518 buffer->pause = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1519 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1520
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1521 /* ...otherwise, do the fadeout first */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1522 xfade_apply_fade_config(&config->fc[FADE_CONFIG_STOP]);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1523
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1524 /* force CONFIG_START in case the user restarts playback during fadeout */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1525 fade_config = &config->fc[FADE_CONFIG_START];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1526 playing = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1527 eop = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1528 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1529 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1530 if(!eop) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1531 DEBUG(("[crossfade] buffer_thread_f: timeout: end of playback\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1532
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1533 /* 0.3.3: undo trailing gap killer at end of playlist */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1534 if(buffer->gap_killed) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1535 buffer->used += buffer->gap_killed;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1536 DEBUG(("[crossfade] buffer_thread_f: timeout:"
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1537 " undoing trailing gap (%d ms)\n", B2MS(buffer->gap_killed)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1538 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1539
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1540 /* do the fadeout if applicable */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1541 if(config->fc[FADE_CONFIG_EOP].type != FADE_TYPE_NONE)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1542 xfade_apply_fade_config(&config->fc[FADE_CONFIG_EOP]);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1543
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1544 fade_config = &config->fc[FADE_CONFIG_START]; /* see above */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1545 eop = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1546 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1547
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1548 if(buffer->used == 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1549 if(config->output_keep_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1550 /* 0.3.0: play silence while keeping the output opened */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1551 buffer->silence = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1552 buffer->silence_len = MS2B(100);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1553 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1554 else if(buffer->silence_len <= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1555 sync_output();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1556 if(opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1557 DEBUG(("[crossfade] buffer_thread_f: timeout, eop: device has been reopened\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1558 DEBUG(("[crossfade] buffer_thread_f: timeout, eop: -> continuing playback\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1559 eop = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1560 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1561 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1562 DEBUG(("[crossfade] buffer_thread_f: timeout, eop: closing output...\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1563 break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1564 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1565 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1566 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1567 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1568 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1569 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1570 eop = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1571
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1572 /* --------------------------------------------------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1573
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1574 /* get free space in device output buffer
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1575 * NOTE: disk_writer always returns <big int> here */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1576 op_free = the_op->buffer_free() & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1577
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1578 /* continue waiting if there is no room in the device buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1579 if(op_free == 0) continue;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1580
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1581 /* --- Limit OP buffer use (decreases latency) ------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1582
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1583 /* HACK: limit output plugin buffer usage to decrease latency */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1584 if(config->enable_op_max_used) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1585 gint output_time = the_op->output_time();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1586 gint output_used = the_op->written_time() - output_time;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1587 gint output_limit = MS2B(config->op_max_used_ms - MIN(output_used, config->op_max_used_ms));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1588
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1589 if(output_flush_time != output_time) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1590 #ifdef SONGCHANGE_TIMEOUT
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1591 if(timeout < config->songchange_timeout) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1592 /* slow down output, but always write _some_ data */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1593 if(output_limit < in_format.bps/100/2)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1594 output_limit = in_format.bps/100/2;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1595
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1596 if(op_free > output_limit)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1597 op_free = output_limit;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1598 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1599 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1600 if((output_used < config->op_max_used_ms) && (op_free > output_limit))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1601 op_free = output_limit;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1602 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1603 op_free = MIN(op_free, 2304); /* avoid 0 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1604 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1605 #else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1606 /* slow down output, but always write _some_ data */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1607 if(output_limit < in_format.bps/100/2)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1608 output_limit = in_format.bps/100/2;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1609
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1610 if(op_free > output_limit)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1611 op_free = output_limit;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1612 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1613 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1614 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1615
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1616 /* --- write silence --------------------------------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1617
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1618 if(!paused && (buffer->silence <= 0) && (buffer->silence_len >= 4)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1619 /* write as much silence as a) there is left and b) the device can take */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1620 length = buffer->silence_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1621 if(length > op_free) length = op_free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1622
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1623 /* make sure we always operate on stereo sample boundary */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1624 length &= -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1625
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1626 /* HACK: don't stay in here too long when in realtime mode (see below) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1627 if(realtime) gettimeofday(&mark, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1628
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1629 /* write length bytes to the device */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1630 length_bak = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1631 while(length > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1632 data = zero_4k;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1633 blen = sizeof(zero_4k);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1634 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1635
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1636 /* make sure zero_4k is cleared. The effect plugin within
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1637 * the output plugin may have modified this buffer! (0.2.8) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1638 memset(zero_4k, 0, blen);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1639
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1640 /* HACK: the original OSS plugin hangs when writing large
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1641 * blocks (greater than device buffer size) in realtime mode */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1642 if(the_op_config.max_write_enable && (blen > the_op_config.max_write_len))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1643 blen = the_op_config.max_write_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1644
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1645 /* finally, write data */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1646 the_op->write_audio(data, blen);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1647 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1648
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1649 /* HACK: don't stay in here too long (force yielding every 10 ms) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1650 if(realtime) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1651 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1652 dt = (tv.tv_sec - mark.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1653 + (tv.tv_usec - mark.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1654 if(dt >= 10) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1655 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1656 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1657
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1658 /* calculate how many bytes actually have been written */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1659 length = length_bak - length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1660 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1661
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1662 else /* --- write data ------------------------------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1663
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1664 if(!paused && (buffer->preload <= 0) && (buffer->used >= 4)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1665 /* write as much data as a) is available and b) the device can take */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1666 length = buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1667 if(length > op_free) length = op_free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1668
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1669 /* HACK: throttle output (used with fast output plugins) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1670 if(the_op_config.throttle_enable && !realtime && opened
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1671 #ifdef SONGCHANGE_TIMEOUT
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1672 && (timeout < config->songchange_timeout)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1673 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1674 ) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1675 sync = buffer->sync_size - (buffer->size - buffer->used);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1676 if(sync < 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1677 length = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1678 else if(sync < length)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1679 length = sync;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1680 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1681
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1682 /* clip length to silence countdown (if applicable) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1683 if((buffer->silence >= 4) && (length > buffer->silence))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1684 length = buffer->silence;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1685
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1686 /* clip length to reopen countdown (if applicable) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1687 if((buffer->reopen >= 0) && (length > buffer->reopen))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1688 length = buffer->reopen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1689
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1690 /* clip length to pause countdown (if applicable) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1691 if((buffer->pause >= 0) && (length > buffer->pause))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1692 length = buffer->pause;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1693
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1694 /* make sure we always operate on stereo sample boundary */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1695 length &= -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1696
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1697 /* HACK: don't stay in here too long when in realtime mode (see below) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1698 if(realtime) gettimeofday(&mark, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1699
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1700 /* write length bytes to the device */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1701 length_bak = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1702 while(length > 0) {
267
38ee4e7f91e6 [svn] revert changes -- broke the plugin :/
nenolod
parents: 266
diff changeset
1703 data = buffer->data + buffer->rd_index;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1704 blen = buffer->size - buffer->rd_index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1705 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1706
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1707 /* HACK: the original OSS plugin hangs when writing large
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1708 * blocks (greater than device buffer size) in realtime mode */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1709 if(the_op_config.max_write_enable
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1710 && (blen > the_op_config.max_write_len))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1711 blen = the_op_config.max_write_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1712
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1713 /* finally, write data */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1714 the_op->write_audio(data, blen);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1715
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1716 buffer->rd_index = (buffer->rd_index + blen) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1717 buffer->used -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1718 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1719
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1720 /* HACK: don't stay in here too long (force yielding every 10 ms) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1721 if(realtime) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1722 gettimeofday(&tv, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1723 dt = (tv.tv_sec - mark.tv_sec) * 1000
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1724 + (tv.tv_usec - mark.tv_usec) / 1000;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1725 if(dt >= 10) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1726 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1727 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1728
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1729 /* calculate how many bytes actually have been written */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1730 length = length_bak - length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1731 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1732 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1733 length = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1734
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1735 /* update realtime throttling */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1736 output_written += length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1737 output_streampos += length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1738
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1739 /* --- check countdowns ------------------------------------------------ */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1740
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1741 if(buffer->silence > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1742 buffer->silence -= length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1743 if(buffer->silence < 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1744 DEBUG(("[crossfade] buffer_thread_f: WARNING: silence overrun: %d\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1745 buffer->silence));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1746 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1747 else if(buffer->silence_len > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1748 buffer->silence_len -= length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1749 if(buffer->silence_len <= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1750 if(buffer->silence_len < 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1751 DEBUG(("[crossfade] buffer_thread_f: WARNING: silence_len overrun: %d\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1752 buffer->silence_len));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1753 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1754 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1755
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1756 if((buffer->reopen >= 0) && !((buffer->silence <= 0) && (buffer->silence_len > 0))) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1757 buffer->reopen -= length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1758 if(buffer->reopen <= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1759 if(buffer->reopen < 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1760 DEBUG(("[crossfade] buffer_thread_f: WARNING: reopen overrun: %d\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1761 buffer->reopen));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1762
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1763 DEBUG(("[crossfade] buffer_thread_f: closing/reopening device\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1764 if(buffer->reopen_sync) sync_output();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1765
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1766 if(the_op->close_audio) the_op->close_audio();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1767 if(!the_op->open_audio(out_format.fmt, out_format.rate, out_format.nch)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1768 DEBUG(("[crossfade] buffer_thread_f: reopening output plugin failed!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1769 g_free(buffer->data);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1770 output_opened = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1771 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1772 g_thread_exit(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1773 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1774
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1775 output_flush_time = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1776 output_written = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1777 output_streampos = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1778
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1779 /* We need to take the leading gap killer into account here:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1780 * It will fix streampos only after gapkilling has finished.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1781 * So, if gapkilling is still in progress at this point, we
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1782 * have to fix it ourselves. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1783 output_offset = buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1784 if((buffer->gap_len > 0) && (buffer->gap > 0))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1785 output_offset += buffer->gap_len - buffer->gap;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1786 output_offset = B2MS(output_offset) - xfade_written_time();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1787
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1788 /* make sure reopen is not 0 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1789 buffer->reopen = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1790 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1791 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1792
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1793 if(buffer->pause >= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1794 buffer->pause -= length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1795 if(buffer->pause <= 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1796 if(buffer->pause < 0)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1797 DEBUG(("[crossfade] buffer_thread_f: WARNING: pause overrun: %d\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1798 buffer->pause));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1799
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1800 DEBUG(("[crossfade] buffer_thread_f: pausing output\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1801
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1802 paused = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1803 sync_output();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1804
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1805 if(!paused)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1806 DEBUG(("[crossfade] buffer_thread_f: unpause during sync\n"))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1807 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1808 the_op->pause(1);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1809
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1810 buffer->pause = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1811 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1812 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1813 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1814
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1815 /* ----------------------------------------------------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1816
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1817 /* cleanup: close output */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1818 if(output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1819 xfade_stop_monitor();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1820
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1821 if(!finishing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1822 if(the_op->close_audio) the_op->close_audio();
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1823 g_free(buffer->data);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1824 output_opened = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1825 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1826 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1827 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1828 DEBUG(("[crossfade] buffer_thread_f: output already closed!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1829
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1830 /* acknowledge 'finishing' (see fini()) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1831 finishing = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1832
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1833 /* ----------------------------------------------------------------------- */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1834
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1835 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1836 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1837
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1838 /* done */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1839 DEBUG(("[crossfade] buffer_thread_f: thread finished\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1840 g_thread_exit(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1841
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1842 return NULL; /* avoid compiler warning */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1843 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1844
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1845 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1846 xfade_close_audio()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1847 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1848 DEBUG(("[crossfade] close:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1849
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1850 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1851 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1852
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1853 /* sanity... the vorbis plugin likes to call close_audio() twice */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1854 if(!opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1855 DEBUG(("[crossfade] close: WARNING: not opened!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1856 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1857 return;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1858 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1859
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1860 /* HACK: FIXME: */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1861 if(input_stopped_for_restart && input_stopped_for_restart())
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1862 DEBUG(("[crossfade] close: playback will restart soon\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1863
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1864 if(playing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1865 /* immediatelly close output when paused */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1866 if(paused) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1867 buffer->pause = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1868 paused = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1869 if(config->output_keep_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1870 buffer->used = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1871 the_op->flush(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1872 the_op->pause(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1873 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1874 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1875 stopped = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1876 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1877
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1878 /* HACK: If playlist_get_info_going is not true here,
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1879 * XMMS is about to exit. In this case, we stop
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1880 * the buffer thread before returning from this
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1881 * function. Otherwise, SEGFAULT may occur when
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1882 * XMMS tries to cleanup an output plugin which
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1883 * we are still using.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1884 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1885 * NOTE: This hack has become obsolete as of 0.3.5.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1886 * See output_list_hack().
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1887 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1888 #if 0
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1889 if((xmms_playlist_get_info_going && !*xmms_playlist_get_info_going) ||
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1890 (xmms_is_quitting && *xmms_is_quitting)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1891 DEBUG(("[crossfade] close: stop (about to quit)\n"))
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1892
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1893 #if 1
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1894 /* wait for buffer thread to clean up and terminate */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1895 stopped = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1896 while(output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1897 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1898 xmms_usleep(10000);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1899 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1900 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1901 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1902 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1903 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1904 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1905 DEBUG(("[crossfade] close: stop\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1906
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1907 fade_config = &config->fc[FADE_CONFIG_MANUAL];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1908 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1909 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1910 DEBUG(("[crossfade] close: songchange/eop\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1911
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1912 /* kill trailing gap (does not use buffer->gap_*) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1913 if(output_opened && xfade_cfg_gap_trail_enable(config)) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1914 gint gap_len = MS2B(xfade_cfg_gap_trail_len(config)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1915 gint gap_level = xfade_cfg_gap_trail_level(config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1916 gint length = MIN(gap_len, buffer->used);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1917
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1918 DEBUG(("[crossfade] close: len=%d level=%d length=%d\n", gap_len, gap_level, length));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1919
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1920 buffer->gap_killed = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1921 while(length > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1922 gint wr_xedni = (buffer->rd_index + buffer->used-1) % buffer->size + 1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1923 gint blen = MIN(length, wr_xedni);
267
38ee4e7f91e6 [svn] revert changes -- broke the plugin :/
nenolod
parents: 266
diff changeset
1924 gint16 *p = buffer->data + wr_xedni;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1925 gint index = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1926
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1927 while(index < blen) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1928 gint16 right = *--p, left = *--p;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1929 if(ABS(left) >= gap_level) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1930 if(ABS(right) >= gap_level) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1931 index += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1932 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1933
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1934 buffer->used -= index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1935 buffer->gap_killed += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1936
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1937 if(index < blen) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1938 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1939 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1940
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1941 DEBUG(("[crossfade] close: trailing gap size: %d/%d ms\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1942 B2MS(buffer->gap_killed), B2MS(gap_len)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1943 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1944
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1945 /* skip to previous zero crossing */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1946 if(output_opened && config->gap_crossing) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1947 int crossing;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1948
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1949 buffer->gap_skipped = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1950 for(crossing = 0; crossing<4; crossing++) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1951 while(buffer->used > 0) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1952 gint wr_xedni = (buffer->rd_index + buffer->used-1) % buffer->size + 1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1953 gint blen = MIN(buffer->used, wr_xedni);
267
38ee4e7f91e6 [svn] revert changes -- broke the plugin :/
nenolod
parents: 266
diff changeset
1954 gint16 *p = buffer->data + wr_xedni;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1955 gint index = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1956
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1957 while(index < blen) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1958 gint16 left = (--p, *--p);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1959 if((crossing & 1) ^ (left > 0)) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1960 index += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1961 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1962
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1963 buffer->used -= index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1964 buffer->gap_skipped += index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1965
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1966 if(index < blen) break;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1967 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1968 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1969 DEBUG(("[crossfade] close: skipped %d bytes to previous zero crossing\n", buffer->gap_skipped));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1970
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1971 /* update gap_killed (for undoing gap_killer in case of EOP) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1972 buffer->gap_killed += buffer->gap_skipped;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1973 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1974
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1975 fade_config = &config->fc[FADE_CONFIG_XFADE];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1976 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1977
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1978 /* XMMS has left the building */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1979 opened = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1980
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1981 /* update last_close */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1982 gettimeofday(&last_close, NULL);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1983 input_playing = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1984
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1985 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1986 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1987 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1988
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1989 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1990 xfade_flush(gint time)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1991 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1992 DEBUG(("[crossfade] flush: time=%d\n", time));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1993
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1994 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1995 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1996
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1997 /* update streampos with new stream position (input format size) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1998 streampos = ((gint64)time * in_format.bps / 1000) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
1999
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2000 /* flush output device / apply seek crossfade */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2001 if(config->fc[FADE_CONFIG_SEEK].type == FADE_TYPE_FLUSH) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2002 /* flush output plugin */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2003 the_op->flush(time);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2004 output_flush_time = time;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2005 output_streampos = MS2B(time);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2006
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2007 /* flush buffer, disable leading gap killing */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2008 buffer_reset(buffer, config);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2009 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2010 else if(paused) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2011 fade_config_t fc;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2012
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2013 /* clear buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2014 buffer->used = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2015
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2016 /* apply only the fade_in part of FADE_CONFIG_PAUSE */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2017 memcpy(&fc, &config->fc[FADE_CONFIG_PAUSE], sizeof(fc));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2018 fc.out_len_ms = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2019 fc.ofs_custom_ms = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2020 xfade_apply_fade_config(&fc);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2021 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2022 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2023 xfade_apply_fade_config(&config->fc[FADE_CONFIG_SEEK]);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2024
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2025 /* restart realtime throttling (should find another name for that var) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2026 output_written = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2027
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2028 /* make sure that the gapkiller is disabled */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2029 buffer->gap = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2030
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2031 /* update output offset */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2032 output_offset = the_op->written_time() - time
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2033 + B2MS(buffer->used) + B2MS(buffer->silence_len);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2034
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2035 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2036 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2037
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2038 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2039 DEBUG(("[crossfade] flush: time=%d: done.\n", time));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2040 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2041 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2042
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2043 void
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2044 xfade_pause(short p)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2045 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2046 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2047 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2048
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2049 if(p) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2050 fade_config_t *fc = &config->fc[FADE_CONFIG_PAUSE];
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2051 if(fc->type == FADE_TYPE_PAUSE_ADV) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2052 int fade, length, n;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2053 int index = buffer->rd_index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2054 int out_len = MS2B(xfade_cfg_fadeout_len(fc)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2055 int in_len = MS2B(xfade_cfg_fadein_len(fc)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2056 int silence_len = MS2B(xfade_cfg_offset(fc)) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2057
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2058 /* limit fadeout/fadein len to available data in buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2059 if((out_len + in_len) > buffer->used) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2060 out_len = (buffer->used / 2) & -4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2061 in_len = out_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2062 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2063
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2064 DEBUG(("[crossfade] pause: paused=1 out=%d in=%d silence=%d\n",
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2065 B2MS(out_len), B2MS(in_len), B2MS(silence_len)));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2066
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2067 /* fade out (modifies buffer directly) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2068 fade = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2069 length = out_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2070 while(length > 0) {
267
38ee4e7f91e6 [svn] revert changes -- broke the plugin :/
nenolod
parents: 266
diff changeset
2071 gint16 *p = buffer->data + index;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2072 gint blen = buffer->size - index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2073 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2074
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2075 for(n = blen/4; n > 0; n--) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2076 gfloat factor = 1.0f - ((gfloat)fade / out_len);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2077 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2078 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2079 fade += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2080 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2081
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2082 index = (index + blen) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2083 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2084 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2085
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2086 /* fade in (modifies buffer directly) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2087 fade = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2088 length = in_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2089 while(length > 0) {
267
38ee4e7f91e6 [svn] revert changes -- broke the plugin :/
nenolod
parents: 266
diff changeset
2090 gint16 *p = buffer->data + index;
259
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2091 gint blen = buffer->size - index;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2092 if(blen > length) blen = length;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2093
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2094 for(n = blen/4; n > 0; n--) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2095 gfloat factor = (gfloat)fade / in_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2096 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2097 *p = (gfloat)*p * factor; p++;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2098 fade += 4;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2099 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2100
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2101 index = (index + blen) % buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2102 length -= blen;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2103 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2104
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2105 /* start silence and pause countdowns */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2106 buffer->silence = out_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2107 buffer->silence_len = silence_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2108 buffer->pause = out_len + silence_len;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2109 paused = FALSE; /* (!) will be set to TRUE in buffer_thread_f */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2110 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2111 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2112 the_op->pause(1);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2113 paused = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2114 DEBUG(("[crossfade] pause: paused=1\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2115 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2116 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2117 else {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2118 the_op->pause(0);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2119 buffer->pause = -1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2120 paused = FALSE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2121 DEBUG(("[crossfade] pause: paused=0\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2122 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2123
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2124 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2125 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2126 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2127
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2128 gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2129 xfade_buffer_free()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2130 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2131 gint size, free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2132
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2133 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2134 DEBUG(("[crossfade] buffer_free:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2135 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2136
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2137 /* sanity check */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2138 if(!output_opened) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2139 DEBUG(("[crossfade] buffer_free: WARNING: output closed!\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2140 return buffer->sync_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2141 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2142
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2143 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2144 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2145
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2146 size = buffer->size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2147
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2148 /* When running in realtime mode, we need to take special care here:
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2149 * While XMMS is writing data to the output plugin, it will not yield
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2150 * ANY processing time to the buffer thread. It will only stop when
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2151 * xfade_buffer_free() no longer reports free buffer space. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2152 if(realtime) {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2153 gint64 wanted = output_written + buffer->preload_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2154
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2155 /* Fix for XMMS misbehaviour (possibly a bug): If the free space as
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2156 * returned by xfade_buffer_free() is below a certain minimum block size
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2157 * (tests showed 2304 bytes), XMMS will not send more data until there
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2158 * is enough room for one of those blocks.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2159 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2160 * This breaks preloading in realtime mode. To make sure that the pre-
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2161 * load buffer gets filled we request additional sync_size bytes. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2162 wanted += buffer->sync_size;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2163
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2164 if(wanted <= size) size = wanted;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2165 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2166
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2167 free = size - buffer->used;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2168 if(free < 0) free = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2169
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2170 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2171 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2172
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2173 /* Convert to input format size. For input rates > output rate this will
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2174 * return less free space than actually is available, but we don't care. */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2175 free /= (out_format.rate / (in_format.rate+1)) + 1;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2176 if(in_format.is_8bit) free /= 2;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2177 if(in_format.nch == 1) free /= 2;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2178
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2179 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2180 DEBUG(("[crossfade] buffer_free: %d\n", free));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2181 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2182 return free;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2183 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2184
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2185 gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2186 xfade_buffer_playing()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2187 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2188 /* always return FALSE here (if not in pause) so XMMS immediatelly
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2189 * starts playback of the next song */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2190
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2191 /*
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2192 * NOTE: this causes trouble when playing HTTP audio streams.
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2193 *
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2194 * mpg123.lib will start prebuffering (and thus stalling output) when both
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2195 * 1) it's internal buffer is emptied (does happen all the time)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2196 * 2) the output plugin's buffer_playing() (this function) returns FALSE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2197 */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2198
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2199 if(paused)
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2200 playing = TRUE;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2201 else
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2202 playing = (is_http && (buffer->used > 0) && the_op->buffer_playing())
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2203 || ((buffer->reopen >= 0) || (buffer->silence > 0) || (buffer->silence_len > 0));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2204
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2205 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2206 DEBUG(("[crossfade] buffer_playing: %d\n", playing));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2207 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2208 return playing;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2209 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2210
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2211 gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2212 xfade_written_time()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2213 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2214 if(!output_opened) return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2215 return (gint)(streampos * 1000 / in_format.bps);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2216 }
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2217
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2218 gint
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2219 xfade_output_time()
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2220 {
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2221 gint time;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2222
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2223 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2224 DEBUG(("[crossfade] output_time:\n"));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2225 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2226
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2227 /* sanity check (note: this one _does_ happen all the time) */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2228 if(!output_opened) return 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2229
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2230 /* lock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2231 g_static_mutex_lock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2232
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2233 time = the_op->output_time() - output_offset;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2234 if(time < 0) time = 0;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2235
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2236 /* unlock buffer */
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2237 g_static_mutex_unlock(&buffer_mutex);
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2238
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2239 #ifdef DEBUG_HARDCORE
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2240 DEBUG(("[crossfade] output_time: time=%d\n", time));
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2241 #endif
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2242 return time;
88b38e2414a1 [svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff changeset
2243 }