Mercurial > audlegacy
annotate src/audacious/playback.c @ 4413:de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 06:47:48 +0300 |
parents | 313dd79a2d24 |
children | a849b8af8db6 |
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" |
4346 | 43 #include "eventqueue.h" |
2420 | 44 #include "hook.h" |
2313 | 45 #include "input.h" |
46 #include "output.h" | |
47 #include "playlist.h" | |
4346 | 48 #include "pluginenum.h" |
2313 | 49 #include "util.h" |
50 | |
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 | 53 |
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
|
54 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
|
55 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
|
56 { |
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 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 } |
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 |
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 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
|
65 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
|
66 { |
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 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 } |
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 |
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
|
74 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
|
75 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
|
76 { |
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 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
|
78 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
|
79 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
|
80 } |
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 |
3705
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
82 static void |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
83 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
|
84 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
|
85 { |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
86 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
|
87 playback->length = length; |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
88 playback->rate = rate; |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
89 playback->freq = freq; |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
90 playback->nch = nch; |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
91 |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
92 /* 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
|
93 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
|
94 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
|
95 } |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
96 |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
97 static void |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
98 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
|
99 { |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
100 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
|
101 |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
102 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
|
103 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
|
104 } |
38259e9394a2
add InputPlayback::set_params() and InputPlayback::set_title() which will
William Pitcock <nenolod@atheme.org>
parents:
3696
diff
changeset
|
105 |
3152
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
106 void |
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
107 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
|
108 { |
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
109 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
|
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 |
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
|
112 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
|
113 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
|
114 { |
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 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
|
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 |
2313 | 118 gint |
119 playback_get_time(void) | |
120 { | |
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
121 InputPlayback *playback; |
2420 | 122 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
|
123 playback = get_current_input_playback(); |
2313 | 124 |
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
|
125 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
|
126 return -1; |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
127 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
|
128 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
|
129 { |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
130 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
|
131 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
|
132 } |
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
133 if (playback->error) |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
134 return -2; |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
135 if (!playback->playing || |
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
136 (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
|
137 return -1; |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
138 return playback->output->output_time(); |
2313 | 139 } |
140 | |
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
141 gint |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
142 playback_get_length(void) |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
143 { |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
144 InputPlayback *playback; |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
145 g_return_val_if_fail(playback_get_playing(), -1); |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
146 playback = get_current_input_playback(); |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
147 |
3717
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
148 if (playback->length) |
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
149 return playback->length; |
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
150 |
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
151 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
|
152 plugin_set_current((Plugin *)(playback->plugin)); |
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
153 Tuple *tuple = playback->plugin->get_song_tuple(playback->filename); |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
154 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
|
155 return tuple_get_int(tuple, FIELD_LENGTH, NULL); |
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
156 } |
3717
8ec5bb8aac58
playback_get_length(): Support InputPlayback::set_params().
William Pitcock <nenolod@atheme.org>
parents:
3716
diff
changeset
|
157 |
3716
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
158 return -1; |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
159 } |
9489aae0d872
introduce playback_get_length()
Tomasz Mon <desowin@gmail.com>
parents:
3711
diff
changeset
|
160 |
2313 | 161 void |
162 playback_initiate(void) | |
163 { | |
164 PlaylistEntry *entry = NULL; | |
165 Playlist *playlist = playlist_get_active(); | |
166 | |
2420 | 167 g_return_if_fail(playlist_get_length(playlist) != 0); |
2313 | 168 |
3152
c9471f83944c
Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
169 /* 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
|
170 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
|
171 |
2313 | 172 if (playback_get_playing()) |
173 playback_stop(); | |
174 | |
175 entry = playlist_get_entry_to_play(playlist); | |
2420 | 176 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
|
177 #ifdef USE_DBUS |
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
178 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
|
179 #endif |
2592
6f7be3702c5f
[svn] - revert the penalty-based "find something to play" logic of 1.2. it's
nenolod
parents:
2454
diff
changeset
|
180 playback_play_file(entry); |
2313 | 181 |
182 playlist_check_pos_current(playlist); | |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
183 |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
184 hook_call("playback begin", entry); |
2313 | 185 } |
186 | |
187 void | |
188 playback_pause(void) | |
189 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
190 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
191 |
2313 | 192 if (!playback_get_playing()) |
193 return; | |
194 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
195 if ((playback = get_current_input_playback()) == NULL) |
2313 | 196 return; |
197 | |
198 ip_data.paused = !ip_data.paused; | |
199 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
200 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
|
201 { |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
202 plugin_set_current((Plugin *)(playback->plugin)); |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
203 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
|
204 } |
2313 | 205 |
3039
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
206 if (ip_data.paused) |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
207 hook_call("playback pause", NULL); |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
208 else |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
209 hook_call("playback unpause", NULL); |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
210 |
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
211 #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
|
212 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
|
213 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
|
214 else |
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_PLAY); |
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
216 #endif |
2313 | 217 } |
218 | |
219 void | |
220 playback_stop(void) | |
221 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
222 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
|
223 |
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
224 if ((playback = get_current_input_playback()) == NULL) |
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
225 return; |
2313 | 226 |
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
|
227 if (ip_data.playing) |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
228 { |
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
|
229 /* 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
|
230 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
|
231 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
|
232 |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
233 if (playback_get_paused() == TRUE) |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
234 { |
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
|
235 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
|
236 output_flush(get_written_time()); /* to avoid noise */ |
2313 | 237 playback_pause(); |
238 } | |
239 | |
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
|
240 ip_data.playing = FALSE; |
2313 | 241 |
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
|
242 /* 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
|
243 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
|
244 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
|
245 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
|
246 |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
247 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
|
248 { |
0becb809bdc9
moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents:
4346
diff
changeset
|
249 plugin_set_current((Plugin *)(playback->plugin)); |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3168
diff
changeset
|
250 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
|
251 } |
2313 | 252 |
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
253 if (playback->thread != NULL) |
3326
6dbb73b8e28c
thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents:
3325
diff
changeset
|
254 { |
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
255 g_thread_join(playback->thread); |
3326
6dbb73b8e28c
thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents:
3325
diff
changeset
|
256 playback->thread = NULL; |
6dbb73b8e28c
thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents:
3325
diff
changeset
|
257 } |
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
258 |
2313 | 259 ip_data.paused = FALSE; |
260 | |
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
|
261 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
|
262 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
|
263 #ifdef USE_DBUS |
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
264 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
|
265 #endif |
2313 | 266 } |
267 | |
268 ip_data.playing = FALSE; | |
3018
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
269 |
4359
0becb809bdc9
moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents:
4346
diff
changeset
|
270 hook_call("playback stop", NULL); |
2313 | 271 } |
272 | |
273 static void | |
274 run_no_output_plugin_dialog(void) | |
275 { | |
276 const gchar *markup = | |
277 N_("<b><big>No output plugin selected.</big></b>\n" | |
278 "You have not selected an output plugin."); | |
279 | |
280 GtkWidget *dialog = | |
281 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
282 GTK_DIALOG_DESTROY_WITH_PARENT, | |
283 GTK_MESSAGE_ERROR, | |
284 GTK_BUTTONS_OK, | |
285 _(markup)); | |
286 gtk_dialog_run(GTK_DIALOG(dialog)); | |
287 gtk_widget_destroy(dialog); | |
288 } | |
289 | |
3153
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
290 static gpointer |
3154
732cfad87116
Made a mistake here. Fixing!
William Pitcock <nenolod@atheme-project.org>
parents:
3153
diff
changeset
|
291 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
|
292 { |
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
293 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
|
294 |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
295 plugin_set_current((Plugin *)(playback->plugin)); |
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
296 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
|
297 |
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
|
298 /* 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
|
299 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
|
300 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
|
301 |
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
|
302 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
|
303 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
|
304 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
|
305 playback_error(); |
3153
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
306 |
3181
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
307 playback->thread = NULL; |
1596dcb77acd
Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3170
diff
changeset
|
308 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
|
309 return NULL; |
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
310 } |
e0a2ea93f98f
New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents:
3152
diff
changeset
|
311 |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
312 InputPlayback * |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
313 playback_new(void) |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
314 { |
3711 | 315 InputPlayback *playback = (InputPlayback *) g_slice_new0(InputPlayback); |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
316 |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
317 playback->pb_ready_mutex = g_mutex_new(); |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
318 playback->pb_ready_cond = g_cond_new(); |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
319 playback->pb_ready_val = 0; |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
320 |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
321 playback->pb_change_mutex = g_mutex_new(); |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
322 playback->pb_change_cond = g_cond_new(); |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
323 |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
324 /* init vtable functors */ |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
325 playback->set_pb_ready = playback_set_pb_ready; |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
326 playback->set_pb_change = playback_set_pb_change; |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
327 playback->set_params = playback_set_pb_params; |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
328 playback->set_title = playback_set_pb_title; |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
329 playback->pass_audio = output_pass_audio; |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4109
diff
changeset
|
330 playback->set_replaygain_info = output_set_replaygain_info; |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
331 |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
332 return playback; |
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 |
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
|
335 /** |
2d6fd3f630f0
Adds playback_free() function to fix memory leak in playback_stop(). (Bugzilla #42)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
3926
diff
changeset
|
336 * 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
|
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 * 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
|
339 * 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
|
340 * 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
|
341 */ |
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 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
|
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 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
|
345 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
|
346 |
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_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
|
348 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
|
349 |
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_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
|
351 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
|
352 |
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_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
|
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 |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
356 void |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
357 playback_run(InputPlayback *playback) |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
358 { |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
359 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
|
360 } |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
361 |
2313 | 362 gboolean |
363 playback_play_file(PlaylistEntry *entry) | |
364 { | |
3254 | 365 InputPlayback *playback; |
366 | |
2313 | 367 g_return_val_if_fail(entry != NULL, FALSE); |
368 | |
369 if (!get_current_output_plugin()) { | |
370 run_no_output_plugin_dialog(); | |
371 mainwin_stop_pushed(); | |
372 return FALSE; | |
373 } | |
374 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
375 if (!entry->decoder) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
376 { |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
377 ProbeResult *pr = input_check_file(entry->filename, FALSE); |
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 if (pr != NULL) |
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 entry->decoder = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
382 entry->tuple = pr->tuple; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
383 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
384 g_free(pr); |
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 } |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
387 |
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
|
388 if (!entry->decoder || !entry->decoder->enabled) |
2313 | 389 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
390 set_current_input_playback(NULL); |
2313 | 391 |
392 return FALSE; | |
393 } | |
394 | |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
395 ip_data.playing = TRUE; |
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
396 |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
397 playback = playback_new(); |
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
398 |
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
399 entry->decoder->output = &psuedo_output_plugin; |
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 playback->plugin = entry->decoder; |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
402 playback->filename = g_strdup(entry->filename); |
3253
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
403 playback->output = &psuedo_output_plugin; |
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
404 |
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
405 set_current_input_playback(playback); |
6374d66ee623
proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents:
3252
diff
changeset
|
406 |
3710
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
407 playback_run(playback); |
602002306969
generic playback control API
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
408 |
3346
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
409 #ifdef USE_DBUS |
71d8d93f1bad
Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents:
3326
diff
changeset
|
410 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
|
411 #endif |
2313 | 412 |
4359
0becb809bdc9
moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents:
4346
diff
changeset
|
413 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
|
414 |
2313 | 415 return TRUE; |
416 } | |
417 | |
418 gboolean | |
419 playback_get_playing(void) | |
420 { | |
421 return ip_data.playing; | |
422 } | |
423 | |
424 gboolean | |
425 playback_get_paused(void) | |
426 { | |
427 return ip_data.paused; | |
428 } | |
429 | |
430 void | |
431 playback_seek(gint time) | |
432 { | |
3168
ee8a1ed30826
playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents:
3165
diff
changeset
|
433 InputPlayback *playback = get_current_input_playback(); |
2313 | 434 gboolean restore_pause = FALSE; |
435 gint l=0, r=0; | |
436 | |
2420 | 437 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
|
438 g_return_if_fail(playback != NULL); |
2313 | 439 |
440 /* FIXME WORKAROUND...that should work with all plugins | |
441 * mute the volume, start playback again, do the seek, then pause again | |
442 * -Patrick Sudowe | |
443 */ | |
2420 | 444 if (ip_data.paused) |
2313 | 445 { |
2420 | 446 restore_pause = TRUE; |
447 output_get_volume(&l, &r); | |
448 output_set_volume(0,0); | |
449 playback_pause(); | |
2313 | 450 } |
451 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4235
diff
changeset
|
452 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
|
453 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
|
454 playback->set_pb_change(playback); |
2313 | 455 |
2420 | 456 if (restore_pause) |
2313 | 457 { |
2420 | 458 playback_pause(); |
459 output_set_volume(l, r); | |
2313 | 460 } |
3718
a98b1189777b
add new hook, playback seek, and subscribe mainwin_update_song_info() to it.
William Pitcock <nenolod@atheme.org>
parents:
3717
diff
changeset
|
461 |
3722 | 462 event_queue_timed(100, "playback seek", playback); |
2313 | 463 } |
464 | |
465 void | |
466 playback_seek_relative(gint offset) | |
467 { | |
468 gint time = CLAMP(playback_get_time() / 1000 + offset, | |
469 0, playlist_get_current_length(playlist_get_active()) / 1000 - 1); | |
470 playback_seek(time); | |
471 } |