2
* Copyright (C) 2003-2011 The Music Player Daemon Project
3
* http://www.musicpd.org
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
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.
21
#include "playlist_queue.h"
22
#include "playlist_plugin.h"
23
#include "playlist_any.h"
24
#include "playlist_song.h"
27
#include "input_stream.h"
30
playlist_load_into_queue(const char *uri, struct playlist_provider *source,
31
unsigned start_index, unsigned end_index,
32
struct playlist *dest, struct player_control *pc,
35
enum playlist_result result;
37
char *base_uri = uri != NULL ? g_path_get_dirname(uri) : NULL;
40
i < end_index && (song = playlist_plugin_read(source)) != NULL;
42
if (i < start_index) {
43
/* skip songs before the start index */
44
if (!song_in_database(song))
49
song = playlist_check_translate_song(song, base_uri, secure);
53
result = playlist_append_song(dest, pc, song, NULL);
54
if (result != PLAYLIST_RESULT_SUCCESS) {
55
if (!song_in_database(song))
64
return PLAYLIST_RESULT_SUCCESS;
68
playlist_open_into_queue(const char *uri,
69
unsigned start_index, unsigned end_index,
70
struct playlist *dest, struct player_control *pc,
73
GMutex *mutex = g_mutex_new();
74
GCond *cond = g_cond_new();
76
struct input_stream *is;
77
struct playlist_provider *playlist =
78
playlist_open_any(uri, mutex, cond, &is);
79
if (playlist == NULL) {
82
return PLAYLIST_RESULT_NO_SUCH_LIST;
85
enum playlist_result result =
86
playlist_load_into_queue(uri, playlist, start_index, end_index,
88
playlist_plugin_close(playlist);
91
input_stream_close(is);