| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* |
| 8 |
* Copyright (C) 2011 by |
| 9 |
* Nicholai Main |
| 10 |
* |
| 11 |
* This program is free software; you can redistribute it and/or |
| 12 |
* modify it under the terms of the GNU General Public License |
| 13 |
* as published by the Free Software Foundation; either version 2 |
| 14 |
* of the License, or (at your option) any later version. |
| 15 |
* |
| 16 |
* This program is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with this program; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 24 |
* 02111-1307, USA. |
| 25 |
* |
| 26 |
* DESCRIPTION: |
| 27 |
* |
| 28 |
*--------------------------------------------------------------------- |
| 29 |
*/ |
| 30 |
|
| 31 |
|
| 32 |
#ifndef MUSICPLAYER_H |
| 33 |
#define MUSICPLAYER_H |
| 34 |
|
| 35 |
/* |
| 36 |
Anything that implements all of these functions can play music in prboomplus. |
| 37 |
|
| 38 |
render: If audio output isn't delivered by render (say, for midi out), then the |
| 39 |
player won't be recordable with video capture. In that case, still write 0s to |
| 40 |
the buffer when render is called. |
| 41 |
|
| 42 |
thread safety: Locks are handled in i_sound.c. Don't worry about it. |
| 43 |
|
| 44 |
Timing: If you're outputting to render, your timing should come solely from the |
| 45 |
calls to render, and not some external timing source. That's why things stay |
| 46 |
synced. |
| 47 |
*/ |
| 48 |
|
| 49 |
|
| 50 |
typedef struct |
| 51 |
{ |
| 52 |
// descriptive name of the player, such as "OPL2 Synth" |
| 53 |
const char *(*name)(void); |
| 54 |
|
| 55 |
// samplerate is in hz. return is 1 for success |
| 56 |
int (*init)(int samplerate); |
| 57 |
|
| 58 |
// deallocate structures, cleanup, ... |
| 59 |
void (*shutdown)(void); |
| 60 |
|
| 61 |
// set volume, 0 = off, 15 = max |
| 62 |
void (*setvolume)(int v); |
| 63 |
|
| 64 |
// pause currently running song. |
| 65 |
void (*pause)(void); |
| 66 |
|
| 67 |
// undo pause |
| 68 |
void (*resume)(void); |
| 69 |
|
| 70 |
// return a player-specific handle, or NULL on failure. |
| 71 |
// data does not belong to player, but it will persist as long as unregister is not called |
| 72 |
const void *(*registersong)(const void *data, unsigned len); |
| 73 |
|
| 74 |
// deallocate structures, etc. data is no longer valid |
| 75 |
void (*unregistersong)(const void *handle); |
| 76 |
|
| 77 |
void (*play)(const void *handle, int looping); |
| 78 |
|
| 79 |
// stop |
| 80 |
void (*stop)(void); |
| 81 |
|
| 82 |
// s16 stereo, with samplerate as specified in init. player needs to be able to handle |
| 83 |
// just about anything for nsamp. render can be called even during pause+stop. |
| 84 |
void (*render)(void *dest, unsigned nsamp); |
| 85 |
} music_player_t; |
| 86 |
|
| 87 |
#endif // MUSICPLAYER_H |