annotate src/audacious/playback.c @ 4519:fcd7a800dcd7

remove needless gtk_window_get_position call
author Tomasz Mon <desowin@gmail.com>
date Sun, 27 Apr 2008 23:56:32 +0200
parents a849b8af8db6
children d2fd41d3964e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious development team
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 * Based on BMP:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
6 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
7 * Based on XMMS:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
9 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3093
diff changeset
12 * the Free Software Foundation; under version 3 of the License.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
13 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
17 * GNU General Public License for more details.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3093
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
21 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
22 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
23 * Audacious or using our public API to be a derived work.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
24 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
25
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
27 # include "config.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
28 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
29
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
30 #include <glib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31 #include <glib/gi18n.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
32 #include <glib/gprintf.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
33 #include <stdlib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34 #include <string.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
35 #include <time.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
37 #include <unistd.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
38 #include <sys/types.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
39 #include <sys/stat.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
40 #include <dirent.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
41
2717
6884a2144a01 [svn] - make audacious build again
nenolod
parents: 2663
diff changeset
42 #include "configdb.h"
4346
6a87d1c1da32 remove more ui_* references
mf0102 <0102@gmx.at>
parents: 4345
diff changeset
43 #include "eventqueue.h"
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
44 #include "hook.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
45 #include "input.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
46 #include "output.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
47 #include "playlist.h"
4346
6a87d1c1da32 remove more ui_* references
mf0102 <0102@gmx.at>
parents: 4345
diff changeset
48 #include "pluginenum.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
49 #include "util.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
50
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
51 #include "playback.h"
3152
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
52 #include "playback_evlisteners.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
53
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
54 static PlaybackInfo playback_info = { 0, 0, 0 };
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
55
3319
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
56 static gint
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
57 playback_set_pb_ready(InputPlayback *playback)
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
58 {
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
59 g_mutex_lock(playback->pb_ready_mutex);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
60 playback->pb_ready_val = 1;
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
61 g_cond_signal(playback->pb_ready_cond);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
62 g_mutex_unlock(playback->pb_ready_mutex);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
63 return 0;
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
64 }
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
65
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
66 static gint
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
67 playback_wait_for_pb_ready(InputPlayback *playback)
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
68 {
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
69 g_mutex_lock(playback->pb_ready_mutex);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
70 while (playback->pb_ready_val != 1)
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
71 g_cond_wait(playback->pb_ready_cond, playback->pb_ready_mutex);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
72 g_mutex_unlock(playback->pb_ready_mutex);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
73 return 0;
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
74 }
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
75
3696
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
76 static void
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
77 playback_set_pb_change(InputPlayback *playback)
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
78 {
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
79 g_mutex_lock(playback->pb_change_mutex);
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
80 g_cond_signal(playback->pb_change_cond);
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
81 g_mutex_unlock(playback->pb_change_mutex);
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
82 }
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
83
3705
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
84 static void
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
85 playback_set_pb_params(InputPlayback *playback, gchar *title,
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
86 gint length, gint rate, gint freq, gint nch)
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
87 {
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
88 playback->title = g_strdup(title);
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
89 playback->length = length;
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
90 playback->rate = rate;
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
91 playback->freq = freq;
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
92 playback->nch = nch;
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
93
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
94 /* XXX: this can be removed/merged here someday */
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
95 plugin_set_current((Plugin *)(playback->plugin));
3705
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
96 playback->plugin->set_info(title, length, rate, freq, nch);
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
97 }
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
98
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
99 static void
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
100 playback_set_pb_title(InputPlayback *playback, gchar *title)
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
101 {
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
102 playback->title = g_strdup(title);
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
103
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
104 plugin_set_current((Plugin *)(playback->plugin));
3705
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
105 playback->plugin->set_info_text(title);
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
106 }
38259e9394a2 add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents: 3696
diff changeset
107
3152
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
108 void
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
109 playback_eof(void)
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
110 {
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
111 event_queue("playback eof", playlist_get_active());
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
112 }
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
113
3158
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
114 void
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
115 playback_error(void)
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
116 {
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
117 event_queue("playback audio error", NULL);
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
118 }
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
119
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
120 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
121 playback_get_time(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
122 {
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
123 InputPlayback *playback;
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
124 g_return_val_if_fail(playback_get_playing(), -1);
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
125 playback = get_current_input_playback();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
126
3180
384cb84c968f Gracefully handle playback being NULL even if playback_get_playing() is TRUE during playback init.
Christian Birchinger <joker@netswarm.net>
parents: 3179
diff changeset
127 if (!playback) /* playback can be NULL during init even if playing is TRUE */
384cb84c968f Gracefully handle playback being NULL even if playback_get_playing() is TRUE during playback init.
Christian Birchinger <joker@netswarm.net>
parents: 3179
diff changeset
128 return -1;
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
129 plugin_set_current((Plugin *)(playback->plugin));
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
130 if (playback->plugin->get_time)
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
131 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
132 plugin_set_current((Plugin *)(playback->plugin));
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
133 return playback->plugin->get_time(playback);
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
134 }
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
135 if (playback->error)
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
136 return -2;
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
137 if (!playback->playing ||
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
138 (playback->eof && !playback->output->buffer_playing()))
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
139 return -1;
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
140 return playback->output->output_time();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
141 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
142
3716
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
143 gint
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
144 playback_get_length(void)
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
145 {
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
146 InputPlayback *playback;
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
147 g_return_val_if_fail(playback_get_playing(), -1);
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
148 playback = get_current_input_playback();
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
149
3717
8ec5bb8aac58 playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents: 3716
diff changeset
150 if (playback->length)
8ec5bb8aac58 playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents: 3716
diff changeset
151 return playback->length;
8ec5bb8aac58 playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents: 3716
diff changeset
152
3716
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
153 if (playback && playback->plugin->get_song_tuple) {
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
154 plugin_set_current((Plugin *)(playback->plugin));
3716
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
155 Tuple *tuple = playback->plugin->get_song_tuple(playback->filename);
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
156 if (tuple_get_value_type(tuple, FIELD_LENGTH, NULL) == TUPLE_INT)
3926
05e6d9db003c playback_get_length() had always returned 1 whenever it uses tuple.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3722
diff changeset
157 return tuple_get_int(tuple, FIELD_LENGTH, NULL);
3716
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
158 }
3717
8ec5bb8aac58 playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents: 3716
diff changeset
159
3716
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
160 return -1;
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
161 }
9489aae0d872 introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents: 3711
diff changeset
162
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
163 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
164 playback_initiate(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
165 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
166 PlaylistEntry *entry = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
167 Playlist *playlist = playlist_get_active();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
168
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
169 g_return_if_fail(playlist_get_length(playlist) != 0);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
170
3152
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
171 /* initialize playback event listeners if not done already */
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
172 playback_evlistener_init();
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
173
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
174 if (playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
175 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
176
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
177 entry = playlist_get_entry_to_play(playlist);
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
178 g_return_if_fail(entry != NULL);
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
179 #ifdef USE_DBUS
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
180 mpris_emit_track_change(mpris);
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
181 #endif
2592
6f7be3702c5f [svn] - revert the penalty-based "find something to play" logic of 1.2. it's
nenolod
parents: 2454
diff changeset
182 playback_play_file(entry);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
183
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
184 playlist_check_pos_current(playlist);
3092
1ddeb9f068ab Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents: 3089
diff changeset
185
1ddeb9f068ab Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents: 3089
diff changeset
186 hook_call("playback begin", entry);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
187 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
188
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
189 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
190 playback_pause(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
191 {
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
192 InputPlayback *playback;
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
193
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
194 if (!playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
195 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
196
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
197 if ((playback = get_current_input_playback()) == NULL)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
198 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
199
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
200 ip_data.paused = !ip_data.paused;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
201
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
202 if (playback->plugin->pause)
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
203 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
204 plugin_set_current((Plugin *)(playback->plugin));
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
205 playback->plugin->pause(playback, ip_data.paused);
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
206 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
207
3039
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
208 if (ip_data.paused)
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
209 hook_call("playback pause", NULL);
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
210 else
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
211 hook_call("playback unpause", NULL);
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
212
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
213 #ifdef USE_DBUS
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
214 if (ip_data.paused)
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
215 mpris_emit_status_change(mpris, MPRIS_STATUS_PAUSE);
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
216 else
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
217 mpris_emit_status_change(mpris, MPRIS_STATUS_PLAY);
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
218 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
219 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
220
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
221 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
222 playback_stop(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
223 {
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
224 InputPlayback *playback;
3252
eddeaebaf1c7 - fixed ugly race condition in new threading model; mutexes are also probably required to handle shared access to ip_data
Giacomo Lozito <james@develia.org>
parents: 3251
diff changeset
225
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
226 if ((playback = get_current_input_playback()) == NULL)
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
227 return;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
228
3252
eddeaebaf1c7 - fixed ugly race condition in new threading model; mutexes are also probably required to handle shared access to ip_data
Giacomo Lozito <james@develia.org>
parents: 3251
diff changeset
229 if (ip_data.playing)
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
230 {
3319
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
231 /* wait for plugin to signal it has reached
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
232 the 'playback safe state' before stopping */
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
233 playback_wait_for_pb_ready(playback);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
234
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
235 if (playback_get_paused() == TRUE)
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
236 {
3258
d899694663a7 in playback_stop, do not assume that get_written_time will be always > 0, some plugins do not write to output at all
Giacomo Lozito <james@develia.org>
parents: 3253
diff changeset
237 if (get_written_time() > 0)
d899694663a7 in playback_stop, do not assume that get_written_time will be always > 0, some plugins do not write to output at all
Giacomo Lozito <james@develia.org>
parents: 3253
diff changeset
238 output_flush(get_written_time()); /* to avoid noise */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
239 playback_pause();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
240 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
241
3319
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
242 ip_data.playing = FALSE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
243
3696
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
244 /* TODO: i'm unsure if this will work. we might have to
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
245 signal the change in stop() (e.g. in the plugins
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
246 directly.) --nenolod */
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
247 playback->set_pb_change(playback);
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
248
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
249 if (playback->plugin->stop)
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
250 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
251 plugin_set_current((Plugin *)(playback->plugin));
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
252 playback->plugin->stop(playback);
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
253 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
254
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
255 if (playback->thread != NULL)
3326
6dbb73b8e28c thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents: 3325
diff changeset
256 {
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
257 g_thread_join(playback->thread);
3326
6dbb73b8e28c thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents: 3325
diff changeset
258 playback->thread = NULL;
6dbb73b8e28c thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents: 3325
diff changeset
259 }
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
260
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
261 ip_data.paused = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
262
4109
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
263 playback_free(playback);
3319
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
264 set_current_input_playback(NULL);
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
265 #ifdef USE_DBUS
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
266 mpris_emit_status_change(mpris, MPRIS_STATUS_STOP);
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
267 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
268 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
269
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
270 ip_data.playing = FALSE;
3018
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
271
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
272 hook_call("playback stop", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
273 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
274
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
275 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
276 run_no_output_plugin_dialog(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
277 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
278 const gchar *markup =
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
279 N_("<b><big>No output plugin selected.</big></b>\n"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
280 "You have not selected an output plugin.");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
281
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
282 GtkWidget *dialog =
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
283 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
284 GTK_DIALOG_DESTROY_WITH_PARENT,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
285 GTK_MESSAGE_ERROR,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
286 GTK_BUTTONS_OK,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
287 _(markup));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
288 gtk_dialog_run(GTK_DIALOG(dialog));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
289 gtk_widget_destroy(dialog);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
290 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
291
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
292 static gpointer
3154
732cfad87116 Made a mistake here. Fixing!
William Pitcock <nenolod@atheme-project.org>
parents: 3153
diff changeset
293 playback_monitor_thread(gpointer data)
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
294 {
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
295 InputPlayback *playback = (InputPlayback *) data;
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
296
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
297 plugin_set_current((Plugin *)(playback->plugin));
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
298 playback->plugin->play_file(playback);
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
299
3319
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
300 /* if play_file has not reached the 'safe state' before returning (an error
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
301 occurred), set the playback ready value to 1 now, to allow for proper stop */
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
302 playback_set_pb_ready(playback);
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
303
3158
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
304 if (!playback->error && ip_data.playing)
3156
4a0e216bc825 playback monitor thread: If forced stop occurs, do not queue "playback eof" signal.
William Pitcock <nenolod@atheme-project.org>
parents: 3155
diff changeset
305 playback_eof();
3158
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
306 else if (playback->error)
92717dcb09f6 Send a message from the monitor thread to the main thread for audio errors, like we do with eof condition.
William Pitcock <nenolod@atheme-project.org>
parents: 3156
diff changeset
307 playback_error();
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
308
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
309 playback->thread = NULL;
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
310 g_thread_exit(NULL);
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
311 return NULL;
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
312 }
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
313
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
314 InputPlayback *
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
315 playback_new(void)
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
316 {
3711
21d58602af29 build fix.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3710
diff changeset
317 InputPlayback *playback = (InputPlayback *) g_slice_new0(InputPlayback);
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
318
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
319 playback->pb_ready_mutex = g_mutex_new();
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
320 playback->pb_ready_cond = g_cond_new();
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
321 playback->pb_ready_val = 0;
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
322
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
323 playback->pb_change_mutex = g_mutex_new();
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
324 playback->pb_change_cond = g_cond_new();
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
325
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
326 /* init vtable functors */
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
327 playback->set_pb_ready = playback_set_pb_ready;
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
328 playback->set_pb_change = playback_set_pb_change;
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
329 playback->set_params = playback_set_pb_params;
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
330 playback->set_title = playback_set_pb_title;
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
331 playback->pass_audio = output_pass_audio;
4235
2d4b4f13d10d set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4109
diff changeset
332 playback->set_replaygain_info = output_set_replaygain_info;
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
333
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
334 return playback;
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
335 }
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
336
4109
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
337 /**
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
338 * Destroys InputPlayback.
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
339 *
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
340 * Playback comes from playback_new() function but there can be also
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
341 * other sources for allocated playback data (like filename and title)
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
342 * and this tries to deallocate all that data.
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
343 */
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
344 void playback_free(InputPlayback *playback)
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
345 {
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
346 g_free(playback->filename);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
347 g_free(playback->title);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
348
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
349 g_mutex_free(playback->pb_ready_mutex);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
350 g_cond_free(playback->pb_ready_cond);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
351
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
352 g_mutex_free(playback->pb_change_mutex);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
353 g_cond_free(playback->pb_change_cond);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
354
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
355 g_slice_free(InputPlayback, playback);
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
356 }
2d6fd3f630f0 Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 3926
diff changeset
357
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
358 void
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
359 playback_run(InputPlayback *playback)
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
360 {
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
361 playback->thread = g_thread_create(playback_monitor_thread, playback, TRUE, NULL);
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
362 }
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
363
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
364 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
365 playback_play_file(PlaylistEntry *entry)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
366 {
3254
William Pitcock <nenolod@atheme-project.org>
parents: 3253
diff changeset
367 InputPlayback *playback;
William Pitcock <nenolod@atheme-project.org>
parents: 3253
diff changeset
368
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
369 g_return_val_if_fail(entry != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
370
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
371 if (!get_current_output_plugin()) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
372 run_no_output_plugin_dialog();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
373 mainwin_stop_pushed();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
374 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
375 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
376
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
377 if (!entry->decoder)
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
378 {
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
379 ProbeResult *pr = input_check_file(entry->filename, FALSE);
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
380
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
381 if (pr != NULL)
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
382 {
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
383 entry->decoder = pr->ip;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
384 entry->tuple = pr->tuple;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
385
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
386 g_free(pr);
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
387 }
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
388 }
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
389
3437
3092a8b3fe34 Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents: 3348
diff changeset
390 if (!entry->decoder || !entry->decoder->enabled)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
391 {
2436
f346d30bf5ab [svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents: 2420
diff changeset
392 set_current_input_playback(NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
393
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
394 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
395 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
396
3092
1ddeb9f068ab Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents: 3089
diff changeset
397 ip_data.playing = TRUE;
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
398
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
399 playback = playback_new();
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
400
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
401 entry->decoder->output = &psuedo_output_plugin;
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
402
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
403 playback->plugin = entry->decoder;
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
404 playback->filename = g_strdup(entry->filename);
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
405 playback->output = &psuedo_output_plugin;
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
406
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
407 set_current_input_playback(playback);
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
408
3710
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
409 playback_run(playback);
602002306969 generic playback control API
William Pitcock <nenolod@atheme.org>
parents: 3709
diff changeset
410
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
411 #ifdef USE_DBUS
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
412 mpris_emit_status_change(mpris, MPRIS_STATUS_PLAY);
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
413 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
414
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
415 hook_call("playback play file", NULL);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4346
diff changeset
416
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
417 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
418 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
419
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
420 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
421 playback_get_playing(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
422 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
423 return ip_data.playing;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
424 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
425
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
426 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
427 playback_get_paused(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
428 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
429 return ip_data.paused;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
430 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
431
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
432 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
433 playback_seek(gint time)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
434 {
3168
ee8a1ed30826 playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents: 3165
diff changeset
435 InputPlayback *playback = get_current_input_playback();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
436 gboolean restore_pause = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
437 gint l=0, r=0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
438
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
439 g_return_if_fail(ip_data.playing);
3168
ee8a1ed30826 playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents: 3165
diff changeset
440 g_return_if_fail(playback != NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
441
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
442 /* FIXME WORKAROUND...that should work with all plugins
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
443 * mute the volume, start playback again, do the seek, then pause again
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
444 * -Patrick Sudowe
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
445 */
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
446 if (ip_data.paused)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
447 {
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
448 restore_pause = TRUE;
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
449 output_get_volume(&l, &r);
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
450 output_set_volume(0,0);
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
451 playback_pause();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
452 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
453
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4235
diff changeset
454 plugin_set_current((Plugin *)(playback->plugin));
3168
ee8a1ed30826 playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents: 3165
diff changeset
455 playback->plugin->seek(playback, time);
3696
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3677
diff changeset
456 playback->set_pb_change(playback);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
457
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
458 if (restore_pause)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
459 {
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
460 playback_pause();
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
461 output_set_volume(l, r);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
462 }
3718
a98b1189777b add new hook, playback seek, and subscribe mainwin_update_song_info() to it.
William Pitcock <nenolod@atheme.org>
parents: 3717
diff changeset
463
3722
57935d8ebefa 100ms delay
William Pitcock <nenolod@atheme.org>
parents: 3720
diff changeset
464 event_queue_timed(100, "playback seek", playback);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
465 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
466
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
467 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
468 playback_seek_relative(gint offset)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
469 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
470 gint time = CLAMP(playback_get_time() / 1000 + offset,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
471 0, playlist_get_current_length(playlist_get_active()) / 1000 - 1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
472 playback_seek(time);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
473 }
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
474
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
475 void
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
476 playback_get_sample_params(gint * bitrate,
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
477 gint * frequency,
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
478 gint * n_channels)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
479 {
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
480 if (bitrate)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
481 *bitrate = playback_info.bitrate;
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
482
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
483 if (frequency)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
484 *frequency = playback_info.frequency;
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
485
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
486 if (n_channels)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
487 *n_channels = playback_info.n_channels;
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
488 }
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
489
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
490 void
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
491 playback_set_sample_params(gint bitrate,
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
492 gint frequency,
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
493 gint n_channels)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
494 {
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
495 if (bitrate >= 0)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
496 playback_info.bitrate = bitrate;
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
497
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
498 if (frequency >= 0)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
499 playback_info.frequency = frequency;
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
500
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
501 if (n_channels >= 0)
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
502 playback_info.n_channels = n_channels;
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
503 }