annotate src/audacious/playback.c @ 3514:331bfc72ef66 trunk

Convert some things to use GSlice.
author William Pitcock <nenolod@atheme.org>
date Tue, 11 Sep 2007 20:29:53 -0500
parents 3092a8b3fe34
children 30ef1287da19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious development team
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 * Based on BMP:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
6 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
7 * Based on XMMS:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
9 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3093
diff changeset
12 * the Free Software Foundation; under version 3 of the License.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
13 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
17 * GNU General Public License for more details.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3093
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
21 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
22 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
23 * Audacious or using our public API to be a derived work.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
24 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
25
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
27 # include "config.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
28 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
29
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
30 #include <glib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31 #include <glib/gi18n.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
32 #include <glib/gprintf.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
33 #include <stdlib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34 #include <string.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
35 #include <time.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
37 #include <unistd.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
38 #include <sys/types.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
39 #include <sys/stat.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
40 #include <dirent.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
41
2717
6884a2144a01 [svn] - make audacious build again
nenolod
parents: 2663
diff changeset
42 #include "configdb.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
43
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
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
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
46 #include "input.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
47 #include "main.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
48 #include "ui_equalizer.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
49 #include "output.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
50 #include "playlist.h"
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
51 #include "ui_main.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
52 #include "ui_playlist.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
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
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
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
f02623377013 goodbye widgets directory
Tomasz Mon <desowin@gmail.com>
parents: 3182
diff changeset
57 #include "skin.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
58
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
59 #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
60 #include "playback_evlisteners.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
61
3018
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
62 static int song_info_timeout_source = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
63
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
64
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
65 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
66 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
67 {
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 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
69 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
70 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
71 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
72 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
73 }
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
74
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
75 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
76 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
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 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
79 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
80 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
81 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
82 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
83 }
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
3152
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
85 void
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
86 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
87 {
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
88 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
89 }
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
90
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
91 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
92 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
93 {
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
94 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
95 }
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
96
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
97 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
98 playback_get_time(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
99 {
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
100 InputPlayback *playback;
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
101 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
102 playback = get_current_input_playback();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
103
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
104 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
105 return -1;
2438
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
106 if (playback->plugin->get_time)
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
107 return playback->plugin->get_time(playback);
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
108 if (playback->error)
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
109 return -2;
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
110 if (!playback->playing ||
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
111 (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
112 return -1;
8750a62abed8 [svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents: 2436
diff changeset
113 return playback->output->output_time();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
114 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
115
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
116 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
117 playback_initiate(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
118 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
119 PlaylistEntry *entry = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
120 Playlist *playlist = playlist_get_active();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
121
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
122 g_return_if_fail(playlist_get_length(playlist) != 0);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
123
3152
c9471f83944c Add playback_eof(). Plugins should use this instead of playback->eof = 1.
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
124 /* 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
125 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
126
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
127 if (playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
128 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
129
3020
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents: 3001
diff changeset
130 ui_vis_clear_data(mainwin_vis);
3054
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents: 3042
diff changeset
131 ui_svis_clear_data(mainwin_svis);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
132 mainwin_disable_seekbar();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
133
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
134 entry = playlist_get_entry_to_play(playlist);
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
135 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
136 #ifdef USE_DBUS
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
137 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
138 #endif
2592
6f7be3702c5f [svn] - revert the penalty-based "find something to play" logic of 1.2. it's
nenolod
parents: 2454
diff changeset
139 playback_play_file(entry);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
140
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
141 // if (playback_get_time() != -1) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
142 equalizerwin_load_auto_preset(entry->filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
143 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
144 cfg.equalizer_bands);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
145 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
146 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
147 // }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
148
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
149 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
150 mainwin_update_song_info();
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
151
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
152 /* 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
153 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
154 (GSourceFunc) mainwin_update_song_info, NULL);
2407
1dc1d36d0347 [svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents: 2366
diff changeset
155
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
156 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
157 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
158 gtk_widget_show(mainwin_stime_sec);
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3041
diff changeset
159 gtk_widget_show(mainwin_sposition);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 3000
diff changeset
160 } else {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 3000
diff changeset
161 gtk_widget_show(mainwin_minus_num);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 3000
diff changeset
162 gtk_widget_show(mainwin_10min_num);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 3000
diff changeset
163 gtk_widget_show(mainwin_min_num);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 3000
diff changeset
164 gtk_widget_show(mainwin_10sec_num);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 3000
diff changeset
165 gtk_widget_show(mainwin_sec_num);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3021
diff changeset
166 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
167 }
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
168
3082
91df04ec5ef7 From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents: 3042
diff changeset
169 vis_playback_start();
3092
1ddeb9f068ab Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents: 3089
diff changeset
170
1ddeb9f068ab Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents: 3089
diff changeset
171 hook_call("playback begin", entry);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
172 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
173
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
174 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
175 playback_pause(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
176 {
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
177 InputPlayback *playback;
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
178
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
179 if (!playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
180 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
181
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
182 if ((playback = get_current_input_playback()) == NULL)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
183 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
184
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
185 ip_data.paused = !ip_data.paused;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
186
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
187 if (playback->plugin->pause)
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
188 playback->plugin->pause(playback, ip_data.paused);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
189
3039
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
190 if (ip_data.paused)
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
191 hook_call("playback pause", NULL);
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
192 else
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
193 hook_call("playback unpause", NULL);
c981df78db8c added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents: 3021
diff changeset
194
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
195 g_return_if_fail(mainwin_playstatus != NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
196
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
197 if (ip_data.paused) {
3072
84de3244aeaa replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents: 3054
diff changeset
198 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
199 #ifdef USE_DBUS
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
200 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
201 #endif
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
202 } else {
3072
84de3244aeaa replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents: 3054
diff changeset
203 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
204 #ifdef USE_DBUS
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
205 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
206 #endif
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
207 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
208 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
209
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
210 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
211 playback_stop(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
212 {
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
213 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
214
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
215 if ((playback = get_current_input_playback()) == NULL)
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
216 return;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
217
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
218 if (ip_data.playing)
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
219 {
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
220 /* 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
221 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
222 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
223
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
224 if (playback_get_paused() == TRUE)
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
225 {
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
226 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
227 output_flush(get_written_time()); /* to avoid noise */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
228 playback_pause();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
229 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
230
3319
d4f6507cded3 added a system that allows input plugins to signal to the core (actually, they MUST do it) that they're ready for playback and it's safe to call their stop function; this fixes a nasty race condition that triggered on fast track-switching
Giacomo Lozito <james@develia.org>
parents: 3259
diff changeset
231 ip_data.playing = FALSE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
232
3170
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
233 if (playback->plugin->stop)
603577228518 get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents: 3168
diff changeset
234 playback->plugin->stop(playback);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
235
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
236 if (playback->thread != NULL)
3326
6dbb73b8e28c thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents: 3325
diff changeset
237 {
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
238 g_thread_join(playback->thread);
3326
6dbb73b8e28c thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents: 3325
diff changeset
239 playback->thread = NULL;
6dbb73b8e28c thread sanity checks
William Pitcock <nenolod@atheme-project.org>
parents: 3325
diff changeset
240 }
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
241
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
242 free_vis_data();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
243 ip_data.paused = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
244
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
245 if (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
246 g_mutex_free(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
247 if (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
248 g_cond_free(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
249
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
250 g_free(playback->filename);
3514
331bfc72ef66 Convert some things to use GSlice.
William Pitcock <nenolod@atheme.org>
parents: 3437
diff changeset
251 g_slice_free(InputPlayback, 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
252 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
253 #ifdef USE_DBUS
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
254 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
255 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
256 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
257
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
258 ip_data.buffering = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
259 ip_data.playing = FALSE;
3018
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
260
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
261 if (song_info_timeout_source)
6a9fdd5aee3a Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents: 3001
diff changeset
262 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
263
3082
91df04ec5ef7 From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents: 3042
diff changeset
264 vis_playback_stop();
91df04ec5ef7 From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents: 3042
diff changeset
265
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
266 g_return_if_fail(mainwin_playstatus != NULL);
3072
84de3244aeaa replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents: 3054
diff changeset
267 ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
268 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
269
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
270 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
271 run_no_output_plugin_dialog(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
272 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
273 const gchar *markup =
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
274 N_("<b><big>No output plugin selected.</big></b>\n"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
275 "You have not selected an output plugin.");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
276
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
277 GtkWidget *dialog =
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
278 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
279 GTK_DIALOG_DESTROY_WITH_PARENT,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
280 GTK_MESSAGE_ERROR,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
281 GTK_BUTTONS_OK,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
282 _(markup));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
283 gtk_dialog_run(GTK_DIALOG(dialog));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
284 gtk_widget_destroy(dialog);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
285 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
286
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
287 static gpointer
3154
732cfad87116 Made a mistake here. Fixing!
William Pitcock <nenolod@atheme-project.org>
parents: 3153
diff changeset
288 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
289 {
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
290 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
291
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
292 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
293
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
294 /* 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
295 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
296 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
297
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
298 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
299 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
300 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
301 playback_error();
3153
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
302
3181
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
303 playback->thread = NULL;
1596dcb77acd Track playback monitor thread in InputPlayback.thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3170
diff changeset
304 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
305 return NULL;
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
306 }
e0a2ea93f98f New threading model for playback. Playback code should now *block*.
William Pitcock <nenolod@atheme-project.org>
parents: 3152
diff changeset
307
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
308 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
309 playback_play_file(PlaylistEntry *entry)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
310 {
3254
William Pitcock <nenolod@atheme-project.org>
parents: 3253
diff changeset
311 InputPlayback *playback;
William Pitcock <nenolod@atheme-project.org>
parents: 3253
diff changeset
312
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
313 g_return_val_if_fail(entry != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
314
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
315 if (!get_current_output_plugin()) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
316 run_no_output_plugin_dialog();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
317 mainwin_stop_pushed();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
318 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
319 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
320
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
321 if (cfg.random_skin_on_play)
2443
93686e8815a4 [svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents: 2438
diff changeset
322 skin_set_random_skin();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
323
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
324 if (!entry->decoder)
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
325 {
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
326 ProbeResult *pr = input_check_file(entry->filename, FALSE);
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
327
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
328 if (pr != NULL)
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
329 {
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
330 entry->decoder = pr->ip;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
331 entry->tuple = pr->tuple;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
332
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
333 g_free(pr);
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
334 }
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
335 }
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
336
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
337 if (!entry->decoder || !entry->decoder->enabled)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
338 {
2436
f346d30bf5ab [svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents: 2420
diff changeset
339 set_current_input_playback(NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
340
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
341 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
342 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
343
3092
1ddeb9f068ab Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents: 3089
diff changeset
344 ip_data.playing = TRUE;
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
345
3514
331bfc72ef66 Convert some things to use GSlice.
William Pitcock <nenolod@atheme.org>
parents: 3437
diff changeset
346 playback = g_slice_new0(InputPlayback);
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
347
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
348 entry->decoder->output = &psuedo_output_plugin;
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
349
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
350 playback->plugin = entry->decoder;
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
351 playback->output = &psuedo_output_plugin;
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
352 playback->filename = g_strdup(entry->filename);
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
353 playback->pb_ready_mutex = g_mutex_new();
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
354 playback->pb_ready_cond = g_cond_new();
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
355 playback->pb_ready_val = 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
356 playback->set_pb_ready = playback_set_pb_ready;
3253
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
357
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
358 set_current_input_playback(playback);
6374d66ee623 proper race condition fix
William Pitcock <nenolod@atheme-project.org>
parents: 3252
diff changeset
359
3325
6f6f38157229 Fix the thread join issue.
William Pitcock <nenolod@atheme-project.org>
parents: 3319
diff changeset
360 playback->thread = g_thread_create(playback_monitor_thread, playback, TRUE, NULL);
3346
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
361 #ifdef USE_DBUS
71d8d93f1bad Implemented TrackChange, StatusChange signals, with a stub for CapsChange.
Ben Tucker <ben.tucker@gmail.com>
parents: 3326
diff changeset
362 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
363 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
364
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
365 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
366 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
367
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
368 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
369 playback_get_playing(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
370 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
371 return ip_data.playing;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
372 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
373
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
374 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
375 playback_get_paused(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
376 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
377 return ip_data.paused;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
378 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
379
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
380 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
381 playback_seek(gint time)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
382 {
3168
ee8a1ed30826 playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents: 3165
diff changeset
383 InputPlayback *playback = get_current_input_playback();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
384 gboolean restore_pause = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
385 gint l=0, r=0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
386
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
387 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
388 g_return_if_fail(playback != NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
389
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
390 /* FIXME WORKAROUND...that should work with all plugins
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
391 * mute the volume, start playback again, do the seek, then pause again
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
392 * -Patrick Sudowe
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
393 */
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
394 if (ip_data.paused)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
395 {
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
396 restore_pause = TRUE;
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
397 output_get_volume(&l, &r);
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
398 output_set_volume(0,0);
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
399 playback_pause();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
400 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
401
3168
ee8a1ed30826 playback_seek(): several WTFs in here (probably from XMMS) fixed
William Pitcock <nenolod@atheme-project.org>
parents: 3165
diff changeset
402 playback->plugin->seek(playback, time);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
403 free_vis_data();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
404
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
405 if (restore_pause)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
406 {
2420
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
407 playback_pause();
b23f52fe132f [svn] Removed util.* from libaudacious
mf0102
parents: 2416
diff changeset
408 output_set_volume(l, r);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
409 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
410 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
411
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
412 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
413 playback_seek_relative(gint offset)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
414 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
415 gint time = CLAMP(playback_get_time() / 1000 + offset,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
416 0, playlist_get_current_length(playlist_get_active()) / 1000 - 1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
417 playback_seek(time);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
418 }