Added ability to shutdown audio output
[2oom.git] / src / audio / avfile.h
blobb6eb5437c8aaa6227da4ab68d5d5d40585533522
1 /** @file avfile.h
2 * Prototypes for audio/video input plugins.
3 * An input plugin provides at least provisions for reading source data from
4 * the VFS, decoding it into one or more raw formats, and rewinding to the
5 * beginning. Optional features include audio-video interleaving or seeking.
6 */
7 /* 2ooM: The Master of Orion II Reverse Engineering Project
8 * Copyright (C) 2006 Nick Bowler
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
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * $HeadURL$
25 * $Date$
26 * $Revision$
27 * $Author$
30 #ifndef _AVFILE_H
31 #define _AVFILE_H
33 #include "audio.h"
35 struct video_format;
37 #define AV_INPUT_AUDIO 1
38 #define AV_INPUT_VIDEO 2
40 #define AV_MODULENAME "AV"
41 #define AV_PLUGIN_SERVICE "AVPLUGIN"
42 #define AV_ACCESS_SERVICE "AVACCESS"
44 struct av_accessor {
45 int (*open)(const char *, int, const struct audio_format *,
46 const struct video_format *);
47 void (*close)(int);
48 int (*read_audio)(int, void *, int);
49 int (*rewind)(int);
50 struct av_accessor *next;
53 int av_init(void);
55 /** Attempt to open the specified VFS resource as media.
56 * The specified resource will be opened by each input plugin in turn, until
57 * one accepts the input or there are none left. If it is accepted by a plugin,
58 * the returned identifier can be used for accessing raw media data in the
59 * specified formats.
61 * @see av_close
62 * @param resource VFS resource to open.
63 * @param type One or more AV_INPUT_* values, bitwise OR'd together.
64 * @param afmt Audio format for raw data, if audio was requested.
65 * @param vfmt Video format for raw data, if video was requested.
66 * @return Identifier for use with further calls, or -1 on failure.
68 int av_open(const char *resource, int type,
69 const struct audio_format *afmt,
70 const struct video_format *vfmt);
72 /** Free all resources associated with the provided identifier.
74 * @see av_open
75 * @param id Identifier as returned by av_open()
77 void av_close(int id);
79 /** Read up to len bytes of decoded audio data into buffer.
80 * Decode audio data into the raw format associated with the provided
81 * identifier, and store at most len bytes of complete samples into the buffer
82 * pointed to by buf.
84 * @see av_open
85 * @param id Identifier as returned by av_open().
86 * @param buf Pointer to buffer of at least len bytes.
87 * @param len Maximum number of bytes to write.
88 * @return Number of bytes written, or -1 on failure.
90 int av_read_audio(int id, void *buf, int len);
92 /** Rewind the media to the beginning.
94 * @param id Identifier as returned by av_open().
95 * @return 0 on success, -1 on failure.
97 int av_rewind(int id);
99 #endif