Mercurial > audlegacy
annotate src/audacious/playback.c @ 4307:cfaecedace4e
importing of winamp EQ presets library
| author | Eugene Zagidullin <e.asphyx@gmail.com> |
|---|---|
| date | Mon, 25 Feb 2008 02:29:28 +0300 |
| parents | 2b7a74fce100 |
| children | 51b7809c2d87 |
| rev | line source |
|---|---|
| 2313 | 1 /* Audacious - Cross-platform multimedia player |
| 2 * Copyright (C) 2005-2007 Audacious development team | |
| 3 * | |
| 4 * Based on BMP: | |
| 5 * Copyright (C) 2003-2004 BMP development team. | |
| 6 * | |
| 7 * Based on XMMS: | |
| 8 * Copyright (C) 1998-2003 XMMS development team. | |
| 9 * | |
| 10 * This program is free software; you can redistribute it and/or modify | |
| 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 | 13 * |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 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 | 24 */ |
| 25 | |
| 26 #ifdef HAVE_CONFIG_H | |
| 27 # include "config.h" | |
| 28 #endif | |
| 29 | |
| 30 #include <glib.h> | |
| 31 #include <glib/gi18n.h> | |
| 32 #include <glib/gprintf.h> | |
| 33 #include <stdlib.h> | |
| 34 #include <string.h> | |
| 35 #include <time.h> | |
| 36 | |
| 37 #include <unistd.h> | |
| 38 #include <sys/types.h> | |
| 39 #include <sys/stat.h> | |
| 40 #include <dirent.h> | |
| 41 | |
| 2717 | 42 #include "configdb.h" |
| 2313 | 43 |
| 2420 | 44 #include "hook.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
|
45 #include "eventqueue.h" |
| 2313 | 46 #include "input.h" |
| 47 #include "main.h" | |
| 48 #include "ui_equalizer.h" | |
| 49 #include "output.h" | |
| 50 #include "playlist.h" | |
| 2420 | 51 #include "ui_main.h" |
| 2313 | 52 #include "ui_playlist.h" |
| 53 #include "ui_skinselector.h" | |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
54 #include "ui_skinned_playstatus.h" |
| 2313 | 55 #include "util.h" |
|
3082
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
56 #include "visualization.h" |
| 3251 | 57 #include "skin.h" |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
58 #include "pluginenum.h" |
| 2313 | 59 |
| 60 #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
|
61 #include "playback_evlisteners.h" |
| 2313 | 62 |
|
3677
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
63 static gint song_info_timeout_source = 0; |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
64 static gint update_vis_timeout_source = 0; |
| 2313 | 65 |
|
3677
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
66 /* XXX: there has to be a better way than polling here! */ |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
67 static gboolean |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
68 playback_update_vis_func(gpointer unused) |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
69 { |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
70 if (!playback_get_playing()) |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
71 return FALSE; |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
72 |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
73 input_update_vis(playback_get_time()); |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
74 |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
75 return TRUE; |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
76 } |
|
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
|
77 |
|
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
|
78 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
|
79 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
|
80 { |
|
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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 } |
|
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
|
87 |
|
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
|
88 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
|
89 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
|
90 { |
|
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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 } |
|
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
|
97 |
|
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
|
98 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
|
99 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
|
100 { |
|
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3677
diff
changeset
|
101 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
|
102 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
|
103 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
|
104 } |
|
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3677
diff
changeset
|
105 |
|
3705
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
106 static void |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
107 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
|
108 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
|
109 { |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
110 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
|
111 playback->length = length; |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
112 playback->rate = rate; |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
113 playback->freq = freq; |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
114 playback->nch = nch; |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
115 |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
116 /* 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
|
117 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
|
118 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
|
119 } |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
120 |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
121 static void |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
122 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
|
123 { |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
124 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
|
125 |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
126 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
|
127 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
|
128 } |
|
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
129 |
|
3152
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
130 void |
|
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
131 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
|
132 { |
|
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
133 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
|
134 } |
|
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
135 |
|
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
|
136 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
|
137 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
|
138 { |
|
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
|
139 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
|
140 } |
|
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
|
141 |
| 2313 | 142 gint |
| 143 playback_get_time(void) | |
| 144 { | |
|
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
145 InputPlayback *playback; |
| 2420 | 146 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
|
147 playback = get_current_input_playback(); |
| 2313 | 148 |
|
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
|
149 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
|
150 return -1; |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
151 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
|
152 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
|
153 { |
|
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)); |
|
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
155 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
|
156 } |
|
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
157 if (playback->error) |
|
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
158 return -2; |
|
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
159 if (!playback->playing || |
|
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
160 (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
|
161 return -1; |
|
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
162 return playback->output->output_time(); |
| 2313 | 163 } |
| 164 | |
|
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
165 gint |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
166 playback_get_length(void) |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
167 { |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
168 InputPlayback *playback; |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
169 g_return_val_if_fail(playback_get_playing(), -1); |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
170 playback = get_current_input_playback(); |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
171 |
|
3717
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
172 if (playback->length) |
|
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
173 return playback->length; |
|
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
174 |
|
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
175 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
|
176 plugin_set_current((Plugin *)(playback->plugin)); |
|
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
177 Tuple *tuple = playback->plugin->get_song_tuple(playback->filename); |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
178 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
|
179 return tuple_get_int(tuple, FIELD_LENGTH, NULL); |
|
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
180 } |
|
3717
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
181 |
|
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
182 return -1; |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
183 } |
|
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
184 |
| 2313 | 185 void |
| 186 playback_initiate(void) | |
| 187 { | |
| 188 PlaylistEntry *entry = NULL; | |
| 189 Playlist *playlist = playlist_get_active(); | |
| 190 | |
| 2420 | 191 g_return_if_fail(playlist_get_length(playlist) != 0); |
| 2313 | 192 |
|
3152
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
193 /* 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
|
194 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
|
195 |
| 2313 | 196 if (playback_get_playing()) |
| 197 playback_stop(); | |
| 198 | |
| 3020 | 199 ui_vis_clear_data(mainwin_vis); |
| 3054 | 200 ui_svis_clear_data(mainwin_svis); |
| 2313 | 201 mainwin_disable_seekbar(); |
| 202 | |
| 203 entry = playlist_get_entry_to_play(playlist); | |
| 2420 | 204 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
|
205 #ifdef USE_DBUS |
|
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
206 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
|
207 #endif |
|
2592
6f7be3702c5f
[svn] - revert the penalty-based "find something to play" logic of 1.2. it's
nenolod
parents:
2454
diff
changeset
|
208 playback_play_file(entry); |
| 2313 | 209 |
|
3179
d2eae001e562
I don't think that's needed. If you revert it, use playback_get_playing() instead.
Christian Birchinger <joker@netswarm.net>
parents:
3170
diff
changeset
|
210 // if (playback_get_time() != -1) { |
| 2313 | 211 equalizerwin_load_auto_preset(entry->filename); |
| 212 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
| 213 cfg.equalizer_bands); | |
| 214 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
| 215 cfg.equalizer_bands); | |
|
3179
d2eae001e562
I don't think that's needed. If you revert it, use playback_get_playing() instead.
Christian Birchinger <joker@netswarm.net>
parents:
3170
diff
changeset
|
216 // } |
| 2313 | 217 |
| 218 playlist_check_pos_current(playlist); | |
|
3018
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
219 mainwin_update_song_info(); |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
220 |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
221 /* FIXME: use g_timeout_add_seconds when glib-2.14 is required */ |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
222 song_info_timeout_source = g_timeout_add(1000, |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
223 (GSourceFunc) mainwin_update_song_info, NULL); |
|
2407
1dc1d36d0347
[svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents:
2366
diff
changeset
|
224 |
|
3677
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
225 update_vis_timeout_source = g_timeout_add(10, |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
226 (GSourceFunc) playback_update_vis_func, NULL); |
|
30ef1287da19
Seperate the 10hz loop dependent code from the rest of the remaining polling loop.
William Pitcock <nenolod@atheme.org>
parents:
3514
diff
changeset
|
227 |
|
3000
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
228 if (cfg.player_shaded) { |
|
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
229 gtk_widget_show(mainwin_stime_min); |
|
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
230 gtk_widget_show(mainwin_stime_sec); |
|
3042
01ae56759d15
mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
3041
diff
changeset
|
231 gtk_widget_show(mainwin_sposition); |
|
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
232 } else { |
|
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
233 gtk_widget_show(mainwin_minus_num); |
|
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
234 gtk_widget_show(mainwin_10min_num); |
|
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
235 gtk_widget_show(mainwin_min_num); |
|
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
236 gtk_widget_show(mainwin_10sec_num); |
|
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
237 gtk_widget_show(mainwin_sec_num); |
|
3040
067e0186623a
import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
3021
diff
changeset
|
238 gtk_widget_show(mainwin_position); |
|
3000
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
239 } |
|
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
240 |
|
3082
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
241 vis_playback_start(); |
|
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
242 |
|
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
243 hook_call("playback begin", entry); |
| 2313 | 244 } |
| 245 | |
| 246 void | |
| 247 playback_pause(void) | |
| 248 { | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
249 InputPlayback *playback; |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
250 |
| 2313 | 251 if (!playback_get_playing()) |
| 252 return; | |
| 253 | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
254 if ((playback = get_current_input_playback()) == NULL) |
| 2313 | 255 return; |
| 256 | |
| 257 ip_data.paused = !ip_data.paused; | |
| 258 | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
259 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
|
260 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
261 plugin_set_current((Plugin *)(playback->plugin)); |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
262 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
|
263 } |
| 2313 | 264 |
|
3039
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
265 if (ip_data.paused) |
|
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
266 hook_call("playback pause", NULL); |
|
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
267 else |
|
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
268 hook_call("playback unpause", NULL); |
|
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
269 |
| 2313 | 270 g_return_if_fail(mainwin_playstatus != NULL); |
| 271 | |
|
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
272 if (ip_data.paused) { |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
273 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); |
|
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
274 #ifdef USE_DBUS |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
275 mpris_emit_status_change(mpris, MPRIS_STATUS_PAUSE); |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
276 #endif |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
277 } else { |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
278 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); |
|
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
279 #ifdef USE_DBUS |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
280 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
|
281 #endif |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
282 } |
| 2313 | 283 } |
| 284 | |
| 285 void | |
| 286 playback_stop(void) | |
| 287 { | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
288 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
|
289 |
|
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
290 if ((playback = get_current_input_playback()) == NULL) |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
291 return; |
| 2313 | 292 |
|
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
|
293 if (ip_data.playing) |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
294 { |
|
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
|
295 /* 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
|
296 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
|
297 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
|
298 |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
299 if (playback_get_paused() == TRUE) |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
300 { |
|
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
|
301 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
|
302 output_flush(get_written_time()); /* to avoid noise */ |
| 2313 | 303 playback_pause(); |
| 304 } | |
| 305 | |
|
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
|
306 ip_data.playing = FALSE; |
| 2313 | 307 |
|
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
|
308 /* 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
|
309 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
|
310 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
|
311 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
|
312 |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
313 if (playback->plugin->stop) |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
314 { |
|
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
315 plugin_set_current((Plugin *)(playback->plugin)); |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
316 playback->plugin->stop(playback); |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
317 } |
| 2313 | 318 |
|
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
319 if (playback->thread != NULL) |
|
3326
6dbb73b8e28c
thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents:
3325
diff
changeset
|
320 { |
|
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
321 g_thread_join(playback->thread); |
|
3326
6dbb73b8e28c
thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents:
3325
diff
changeset
|
322 playback->thread = NULL; |
|
6dbb73b8e28c
thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents:
3325
diff
changeset
|
323 } |
|
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
324 |
| 2313 | 325 free_vis_data(); |
| 326 ip_data.paused = FALSE; | |
| 327 | |
|
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
|
328 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
|
329 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
|
330 #ifdef USE_DBUS |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
331 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
|
332 #endif |
| 2313 | 333 } |
| 334 | |
| 335 ip_data.buffering = FALSE; | |
| 336 ip_data.playing = FALSE; | |
|
3018
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
337 |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
338 if (song_info_timeout_source) |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
339 g_source_remove(song_info_timeout_source); |
|
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
340 |
|
3082
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
341 vis_playback_stop(); |
|
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
342 |
| 2313 | 343 g_return_if_fail(mainwin_playstatus != NULL); |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
344 ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE); |
| 2313 | 345 } |
| 346 | |
| 347 static void | |
| 348 run_no_output_plugin_dialog(void) | |
| 349 { | |
| 350 const gchar *markup = | |
| 351 N_("<b><big>No output plugin selected.</big></b>\n" | |
| 352 "You have not selected an output plugin."); | |
| 353 | |
| 354 GtkWidget *dialog = | |
| 355 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
| 356 GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 357 GTK_MESSAGE_ERROR, | |
| 358 GTK_BUTTONS_OK, | |
| 359 _(markup)); | |
| 360 gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 361 gtk_widget_destroy(dialog); | |
| 362 } | |
| 363 | |
|
3153
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
364 static gpointer |
|
3154
732cfad87116
Made a mistake here. Fixing!
William Pitcock <nenolod@atheme-project.org>
parents:
3153
diff
changeset
|
365 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
|
366 { |
|
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
367 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
|
368 |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
369 plugin_set_current((Plugin *)(playback->plugin)); |
|
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
370 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
|
371 |
|
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
|
372 /* 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
|
373 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
|
374 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
|
375 |
|
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
|
376 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
|
377 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
|
378 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
|
379 playback_error(); |
|
3153
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
380 |
|
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
381 playback->thread = NULL; |
|
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
382 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
|
383 return NULL; |
|
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
384 } |
|
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
385 |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
386 InputPlayback * |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
387 playback_new(void) |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
388 { |
| 3711 | 389 InputPlayback *playback = (InputPlayback *) g_slice_new0(InputPlayback); |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
390 |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
391 playback->pb_ready_mutex = g_mutex_new(); |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
392 playback->pb_ready_cond = g_cond_new(); |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
393 playback->pb_ready_val = 0; |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
394 |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
395 playback->pb_change_mutex = g_mutex_new(); |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
396 playback->pb_change_cond = g_cond_new(); |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
397 |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
398 /* init vtable functors */ |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
399 playback->set_pb_ready = playback_set_pb_ready; |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
400 playback->set_pb_change = playback_set_pb_change; |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
401 playback->set_params = playback_set_pb_params; |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
402 playback->set_title = playback_set_pb_title; |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
403 playback->pass_audio = output_pass_audio; |
|
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4109
diff
changeset
|
404 playback->set_replaygain_info = output_set_replaygain_info; |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
405 |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
406 return playback; |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
407 } |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
408 |
|
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
|
409 /** |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
410 * 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
|
411 * |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
412 * 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
|
413 * 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
|
414 * 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
|
415 */ |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
416 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
|
417 { |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
418 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
|
419 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
|
420 |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
421 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
|
422 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
|
423 |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
424 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
|
425 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
|
426 |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
427 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
|
428 } |
|
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
429 |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
430 void |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
431 playback_run(InputPlayback *playback) |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
432 { |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
433 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
|
434 } |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
435 |
| 2313 | 436 gboolean |
| 437 playback_play_file(PlaylistEntry *entry) | |
| 438 { | |
| 3254 | 439 InputPlayback *playback; |
| 440 | |
| 2313 | 441 g_return_val_if_fail(entry != NULL, FALSE); |
| 442 | |
| 443 if (!get_current_output_plugin()) { | |
| 444 run_no_output_plugin_dialog(); | |
| 445 mainwin_stop_pushed(); | |
| 446 return FALSE; | |
| 447 } | |
| 448 | |
| 449 if (cfg.random_skin_on_play) | |
|
2443
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2438
diff
changeset
|
450 skin_set_random_skin(); |
| 2313 | 451 |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
452 if (!entry->decoder) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
453 { |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
454 ProbeResult *pr = input_check_file(entry->filename, FALSE); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
455 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
456 if (pr != NULL) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
457 { |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
458 entry->decoder = pr->ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
459 entry->tuple = pr->tuple; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
460 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
461 g_free(pr); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
462 } |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
463 } |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
464 |
|
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
|
465 if (!entry->decoder || !entry->decoder->enabled) |
| 2313 | 466 { |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
467 set_current_input_playback(NULL); |
| 2313 | 468 |
| 469 return FALSE; | |
| 470 } | |
| 471 | |
|
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
472 ip_data.playing = TRUE; |
|
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
473 |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
474 playback = playback_new(); |
|
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
475 |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
476 entry->decoder->output = &psuedo_output_plugin; |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
477 |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
478 playback->plugin = entry->decoder; |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
479 playback->filename = g_strdup(entry->filename); |
|
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
480 playback->output = &psuedo_output_plugin; |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
481 |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
482 set_current_input_playback(playback); |
|
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
483 |
|
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
484 playback_run(playback); |
|
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
485 |
|
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
486 #ifdef USE_DBUS |
|
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
487 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
|
488 #endif |
| 2313 | 489 |
| 490 return TRUE; | |
| 491 } | |
| 492 | |
| 493 gboolean | |
| 494 playback_get_playing(void) | |
| 495 { | |
| 496 return ip_data.playing; | |
| 497 } | |
| 498 | |
| 499 gboolean | |
| 500 playback_get_paused(void) | |
| 501 { | |
| 502 return ip_data.paused; | |
| 503 } | |
| 504 | |
| 505 void | |
| 506 playback_seek(gint time) | |
| 507 { | |
|
3168
ee8a1ed30826
playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
508 InputPlayback *playback = get_current_input_playback(); |
| 2313 | 509 gboolean restore_pause = FALSE; |
| 510 gint l=0, r=0; | |
| 511 | |
| 2420 | 512 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
|
513 g_return_if_fail(playback != NULL); |
| 2313 | 514 |
| 515 /* FIXME WORKAROUND...that should work with all plugins | |
| 516 * mute the volume, start playback again, do the seek, then pause again | |
| 517 * -Patrick Sudowe | |
| 518 */ | |
| 2420 | 519 if (ip_data.paused) |
| 2313 | 520 { |
| 2420 | 521 restore_pause = TRUE; |
| 522 output_get_volume(&l, &r); | |
| 523 output_set_volume(0,0); | |
| 524 playback_pause(); | |
| 2313 | 525 } |
| 526 | |
|
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
527 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
|
528 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
|
529 playback->set_pb_change(playback); |
| 2313 | 530 free_vis_data(); |
| 531 | |
| 2420 | 532 if (restore_pause) |
| 2313 | 533 { |
| 2420 | 534 playback_pause(); |
| 535 output_set_volume(l, r); | |
| 2313 | 536 } |
|
3718
a98b1189777b
add new hook, playback seek, and subscribe mainwin_update_song_info() to it.
William Pitcock <nenolod@atheme.org>
parents:
3717
diff
changeset
|
537 |
| 3722 | 538 event_queue_timed(100, "playback seek", playback); |
| 2313 | 539 } |
| 540 | |
| 541 void | |
| 542 playback_seek_relative(gint offset) | |
| 543 { | |
| 544 gint time = CLAMP(playback_get_time() / 1000 + offset, | |
| 545 0, playlist_get_current_length(playlist_get_active()) / 1000 - 1); | |
| 546 playback_seek(time); | |
| 547 } |
