MPD 0.17~git
src/input_stream.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2011 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #ifndef MPD_INPUT_STREAM_H
00021 #define MPD_INPUT_STREAM_H
00022 
00023 #include "check.h"
00024 #include "gcc.h"
00025 
00026 #include <glib.h>
00027 
00028 #include <stddef.h>
00029 #include <stdbool.h>
00030 #include <sys/types.h>
00031 
00032 #if !GLIB_CHECK_VERSION(2,14,0)
00033 typedef gint64 goffset;
00034 #endif
00035 
00036 struct input_stream {
00040         const struct input_plugin *plugin;
00041 
00046         char *uri;
00047 
00056         GMutex *mutex;
00057 
00066         GCond *cond;
00067 
00072         bool ready;
00073 
00077         bool seekable;
00078 
00082         goffset size;
00083 
00087         goffset offset;
00088 
00092         char *mime;
00093 };
00094 
00106 gcc_nonnull(1, 2)
00107 G_GNUC_MALLOC
00108 struct input_stream *
00109 input_stream_open(const char *uri,
00110                   GMutex *mutex, GCond *cond,
00111                   GError **error_r);
00112 
00118 gcc_nonnull(1)
00119 void
00120 input_stream_close(struct input_stream *is);
00121 
00122 gcc_nonnull(1)
00123 static inline void
00124 input_stream_lock(struct input_stream *is)
00125 {
00126         g_mutex_lock(is->mutex);
00127 }
00128 
00129 gcc_nonnull(1)
00130 static inline void
00131 input_stream_unlock(struct input_stream *is)
00132 {
00133         g_mutex_unlock(is->mutex);
00134 }
00135 
00141 gcc_nonnull(1)
00142 bool
00143 input_stream_check(struct input_stream *is, GError **error_r);
00144 
00149 gcc_nonnull(1)
00150 void
00151 input_stream_update(struct input_stream *is);
00152 
00158 gcc_nonnull(1)
00159 void
00160 input_stream_wait_ready(struct input_stream *is);
00161 
00166 gcc_nonnull(1)
00167 void
00168 input_stream_lock_wait_ready(struct input_stream *is);
00169 
00180 gcc_nonnull(1)
00181 bool
00182 input_stream_seek(struct input_stream *is, goffset offset, int whence,
00183                   GError **error_r);
00184 
00189 gcc_nonnull(1)
00190 bool
00191 input_stream_lock_seek(struct input_stream *is, goffset offset, int whence,
00192                        GError **error_r);
00193 
00199 gcc_nonnull(1)
00200 G_GNUC_PURE
00201 bool input_stream_eof(struct input_stream *is);
00202 
00207 gcc_nonnull(1)
00208 G_GNUC_PURE
00209 bool
00210 input_stream_lock_eof(struct input_stream *is);
00211 
00220 gcc_nonnull(1)
00221 G_GNUC_MALLOC
00222 struct tag *
00223 input_stream_tag(struct input_stream *is);
00224 
00229 gcc_nonnull(1)
00230 G_GNUC_MALLOC
00231 struct tag *
00232 input_stream_lock_tag(struct input_stream *is);
00233 
00241 gcc_nonnull(1)
00242 G_GNUC_PURE
00243 bool
00244 input_stream_available(struct input_stream *is);
00245 
00257 gcc_nonnull(1, 2)
00258 size_t
00259 input_stream_read(struct input_stream *is, void *ptr, size_t size,
00260                   GError **error_r);
00261 
00266 gcc_nonnull(1, 2)
00267 size_t
00268 input_stream_lock_read(struct input_stream *is, void *ptr, size_t size,
00269                        GError **error_r);
00270 
00271 #endif