~ubuntu-dev/ubuntu/lucid/mpd/lucid-201002101854

« back to all changes in this revision

Viewing changes to src/decoder_control.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-10-23 12:38:20 UTC
  • mfrom: (1.1.12 upstream) (2.2.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091023123820-rxt21lmekscxbkbt
Tags: 0.15.4-1ubuntu1
* Merge from debian unstable, Ubuntu remaining changes:
  - debian/control:
    + Don't build-depends on libmikmod2-dev (Debian bug #510675).
    + Move avahi-daemon from Suggests field to Recommends field.
  - debian/mpd.init.d:
    + Read mpd user from mpd.conf.
* Also fixes LP: #332332.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* the Music Player Daemon (MPD)
2
 
 * Copyright (C) 2008 Max Kellermann <max@duempel.org>
3
 
 * This project's homepage is: http://www.musicpd.org
 
1
/*
 
2
 * Copyright (C) 2003-2009 The Music Player Daemon Project
 
3
 * http://www.musicpd.org
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
11
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
 * GNU General Public License for more details.
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
17
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
 */
18
19
 
19
20
#include "decoder_control.h"
59
60
void
60
61
dc_start(struct notify *notify, struct song *song)
61
62
{
 
63
        assert(dc.pipe != NULL);
62
64
        assert(song != NULL);
63
65
 
64
66
        dc.next_song = song;
68
70
void
69
71
dc_start_async(struct song *song)
70
72
{
 
73
        assert(dc.pipe != NULL);
71
74
        assert(song != NULL);
72
75
 
73
76
        dc.next_song = song;
77
80
void
78
81
dc_stop(struct notify *notify)
79
82
{
80
 
        if (dc.command == DECODE_COMMAND_START ||
81
 
            (dc.state != DECODE_STATE_STOP && dc.state != DECODE_STATE_ERROR))
 
83
        if (dc.command != DECODE_COMMAND_NONE)
 
84
                /* Attempt to cancel the current command.  If it's too
 
85
                   late and the decoder thread is already executing
 
86
                   the old command, we'll call STOP again in this
 
87
                   function (see below). */
 
88
                dc_command(notify, DECODE_COMMAND_STOP);
 
89
 
 
90
        if (dc.state != DECODE_STATE_STOP && dc.state != DECODE_STATE_ERROR)
82
91
                dc_command(notify, DECODE_COMMAND_STOP);
83
92
}
84
93
 
85
94
bool
86
95
dc_seek(struct notify *notify, double where)
87
96
{
 
97
        assert(dc.state != DECODE_STATE_START);
88
98
        assert(where >= 0.0);
89
99
 
90
100
        if (dc.state == DECODE_STATE_STOP ||
100
110
 
101
111
        return true;
102
112
}
 
113
 
 
114
void
 
115
dc_quit(void)
 
116
{
 
117
        assert(dc.thread != NULL);
 
118
 
 
119
        dc.quit = true;
 
120
        dc_command_async(DECODE_COMMAND_STOP);
 
121
 
 
122
        g_thread_join(dc.thread);
 
123
        dc.thread = NULL;
 
124
}