2001-10-05 19:36:35 +00:00
|
|
|
/*
|
|
|
|
xmms_cd.c
|
|
|
|
|
|
|
|
XMMS Player support, disguised as a cdrom.
|
|
|
|
|
|
|
|
Copyright (C) 2001 Alexis Paul Musgrave
|
|
|
|
|
|
|
|
Author: Alexis Paul Musgrave
|
|
|
|
Date: 2001/09/28
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-10-05 19:36:35 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <xmmsctrl.h>
|
|
|
|
|
|
|
|
#include "QF/cdaudio.h"
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/sound.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
|
2012-02-13 12:58:34 +00:00
|
|
|
#include "QF/plugin/general.h"
|
|
|
|
#include "QF/plugin/cd.h"
|
|
|
|
|
2001-10-05 19:36:35 +00:00
|
|
|
#include "compat.h"
|
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
static plugin_t plugin_info;
|
|
|
|
static plugin_data_t plugin_info_data;
|
|
|
|
static plugin_funcs_t plugin_info_funcs;
|
|
|
|
static general_data_t plugin_info_general_data;
|
|
|
|
static general_funcs_t plugin_info_general_funcs;
|
|
|
|
|
|
|
|
static cd_funcs_t plugin_info_cd_funcs;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2003-01-06 21:41:46 +00:00
|
|
|
static const char *xmms_cmd = "xmms";
|
|
|
|
static const char *xmms_args[] = {"xmms", 0};
|
2001-10-15 17:37:05 +00:00
|
|
|
// Session number, gets set to 0 in I_XMMS_Init if not set
|
|
|
|
static int sessionNo;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
|
|
|
// don't need either of these now
|
2002-01-10 21:22:51 +00:00
|
|
|
//static int xmmsPid = '0';
|
2001-10-05 19:36:35 +00:00
|
|
|
//static int sigNo = '2';
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool playing = false;
|
2001-10-05 20:29:55 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
// no idea why I have wasPlaying, pbly this code was based on cd_linux.c :/
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool wasPlaying = false;
|
|
|
|
static bool musEnabled = true;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-12 19:26:56 +00:00
|
|
|
static void I_XMMS_Running(void);
|
|
|
|
static void I_XMMS_Stop(void);
|
2023-06-13 09:06:11 +00:00
|
|
|
static void I_XMMS_Play(int, bool);
|
2001-10-12 19:26:56 +00:00
|
|
|
static void I_XMMS_Pause(void);
|
|
|
|
static void I_XMMS_Resume(void);
|
|
|
|
static void I_XMMS_Next(void);
|
|
|
|
static void I_XMMS_Prev(void);
|
|
|
|
static void I_XMMS_Update(void);
|
2001-10-15 17:37:05 +00:00
|
|
|
static void XMMS_SessionChg(cvar_t *);
|
2001-10-12 19:26:56 +00:00
|
|
|
static void I_XMMS_Init(void);
|
|
|
|
static void I_XMMS_Shutdown(void);
|
|
|
|
static void I_XMMS_Kill(void);
|
|
|
|
static void I_XMMS_On(void);
|
|
|
|
static void I_XMMS_Off(void);
|
|
|
|
static void I_XMMS_Shuffle(void);
|
|
|
|
static void I_XMMS_Repeat(void);
|
|
|
|
static void I_XMMS_Pos(int);
|
2001-10-15 17:37:05 +00:00
|
|
|
static void I_XMMS_Info(void);
|
2001-10-12 19:26:56 +00:00
|
|
|
static void I_XMMS_f(void);
|
2004-01-19 07:47:41 +00:00
|
|
|
plugin_t *cd_xmms_PluginInfo (void);
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
//static float cdvolume;
|
|
|
|
//static byte remap[100];
|
|
|
|
//static byte playTrack;
|
|
|
|
//static byte maxTrack;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
|
|
|
// FIXME: All of this code assumes that the xmms_remote_* functions succeed
|
2001-10-15 17:37:05 +00:00
|
|
|
// FIXME: shouldn't I use gint for all the xmms stuff like
|
2004-02-07 05:35:15 +00:00
|
|
|
// FIXME (cont): /usr/include/xmms/xmmsctrl.h says?
|
2001-10-05 19:36:35 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Running (void)
|
|
|
|
{
|
2004-02-07 05:35:15 +00:00
|
|
|
int res, i;
|
2001-10-05 20:29:55 +00:00
|
|
|
int fd_size = getdtablesize ();
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
if (!xmms_remote_is_running (sessionNo)) {
|
2001-10-05 20:29:55 +00:00
|
|
|
// this method is used over a system() call, so that we know child's
|
|
|
|
// pid (not that is particularly important) but so we can close
|
|
|
|
// unneeded descriptors
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
res = fork ();
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
switch (res) {
|
|
|
|
case 0: // Child
|
|
|
|
// Well, we don't want the child to be running about with
|
|
|
|
// 27001 still open
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
for (i = 3; i < fd_size; i++)
|
|
|
|
close (i);
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
// run xmms
|
2003-01-06 21:41:46 +00:00
|
|
|
if (execvp (xmms_cmd, (char **)xmms_args)) {
|
2002-01-10 21:22:51 +00:00
|
|
|
// Oh dear, can we even use Sys_DPrinf? We are child so
|
|
|
|
// we have access to them? But wouldn't it just try
|
|
|
|
// rendering it and screw stuff up? Better not find out.
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
exit (1); // Well, we can't just hang about
|
|
|
|
// causing trouble can we ?
|
|
|
|
}
|
|
|
|
break;
|
2002-01-10 21:22:51 +00:00
|
|
|
case -1: // ICH!
|
2001-10-05 20:29:55 +00:00
|
|
|
// inform user
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_snd, "XMMSAudio: error, can't fork!?\n");
|
2001-10-05 20:29:55 +00:00
|
|
|
break;
|
|
|
|
default: // Parent
|
|
|
|
// don't need now :/
|
2012-05-21 23:23:22 +00:00
|
|
|
// xmmsPid = res; // so we can kill it later
|
2001-10-05 20:29:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2001-10-05 20:29:55 +00:00
|
|
|
I_XMMS_Stop (void) // stop playing
|
2001-10-05 19:36:35 +00:00
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
if (!xmms_remote_is_playing (sessionNo))
|
2001-10-05 20:29:55 +00:00
|
|
|
return; // check that its actually playing
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2002-01-10 21:22:51 +00:00
|
|
|
xmms_remote_stop (sessionNo); // stop it
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
wasPlaying = playing;
|
2001-10-05 19:36:35 +00:00
|
|
|
playing = false;
|
|
|
|
}
|
|
|
|
|
2001-10-12 19:26:56 +00:00
|
|
|
// Play
|
2002-01-10 21:22:51 +00:00
|
|
|
// start it playing, (unless disabled)
|
|
|
|
static void
|
2023-06-13 09:06:11 +00:00
|
|
|
I_XMMS_Play (int track, bool looping) // looping for compatability
|
2001-10-05 19:36:35 +00:00
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
|
|
|
// I think this will fix some wierdness
|
2001-10-15 17:37:05 +00:00
|
|
|
if (xmms_remote_is_paused (sessionNo)) {
|
|
|
|
xmms_remote_pause (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-10-12 19:26:56 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
if (track >= 0)
|
|
|
|
xmms_remote_set_playlist_pos (sessionNo, track);
|
2001-10-12 19:26:56 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
if (xmms_remote_is_playing (sessionNo))
|
|
|
|
return;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
xmms_remote_play (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
|
|
|
|
wasPlaying = playing;
|
|
|
|
playing = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Pause (void)
|
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
if (!xmms_remote_is_playing (sessionNo))
|
2001-10-05 20:29:55 +00:00
|
|
|
return;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
xmms_remote_pause (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
|
|
|
|
wasPlaying = playing;
|
|
|
|
playing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Resume (void)
|
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
|
|
|
// i think this will fix some wierdness
|
2001-10-15 17:37:05 +00:00
|
|
|
if (xmms_remote_is_paused (sessionNo)) {
|
|
|
|
xmms_remote_pause (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-10-15 17:37:05 +00:00
|
|
|
if (xmms_remote_is_playing (sessionNo))
|
2001-10-05 20:29:55 +00:00
|
|
|
return;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
xmms_remote_play (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
wasPlaying = playing;
|
|
|
|
playing = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Prev (void)
|
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
xmms_remote_playlist_prev (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Next (void)
|
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
xmms_remote_playlist_next (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Update (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
static void
|
|
|
|
XMMS_SessionChg(cvar_t *xmms_session)
|
|
|
|
{
|
|
|
|
sessionNo = xmms_session->int_val;
|
|
|
|
}
|
|
|
|
|
2001-10-05 19:36:35 +00:00
|
|
|
static void
|
|
|
|
I_XMMS_Init (void)
|
|
|
|
{
|
2001-10-15 17:37:05 +00:00
|
|
|
cvar_t *tmp;
|
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
I_XMMS_Running ();
|
|
|
|
Cmd_AddCommand ("xmms", I_XMMS_f, "Control the XMMS player.\n"
|
|
|
|
"Commands:\n"
|
|
|
|
"resume - Will resume playback after pause.\n"
|
|
|
|
"off - Stops control and playback of XMMS.\n"
|
|
|
|
"on - Starts XMMS if not running, or enables playback.\n"
|
|
|
|
"pause - Pause the XMMS playback.\n"
|
2002-01-10 21:22:51 +00:00
|
|
|
"play (position) - Begins playing tracks (from position) "
|
|
|
|
"according to the playlist.\n"
|
2001-10-05 20:29:55 +00:00
|
|
|
"stop - Stops the currently playing track.\n"
|
|
|
|
"next - Plays the next track in the playlist.\n"
|
|
|
|
"prev - Plays the previous track in the playlist.\n"
|
|
|
|
"shuffle - Toggle shuffling the playlist.\n"
|
2001-10-12 19:26:56 +00:00
|
|
|
"repeat - Toggle repeating of the playlist.\n"
|
2001-10-15 17:37:05 +00:00
|
|
|
"pos - Set playlist position.\n"
|
|
|
|
"info - Get information about currently playing song.");
|
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
tmp = Cvar_Get ("xmms_session", "0", CVAR_NONE, XMMS_SessionChg,
|
|
|
|
"XMMS Session number to use");
|
2001-10-15 17:37:05 +00:00
|
|
|
|
|
|
|
sessionNo = tmp->int_val;
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Shutdown (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Kill (void)
|
|
|
|
{
|
2001-10-15 17:37:05 +00:00
|
|
|
xmms_remote_quit (sessionNo);
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_On (void)
|
|
|
|
{
|
|
|
|
musEnabled = true;
|
2001-10-05 20:29:55 +00:00
|
|
|
I_XMMS_Running ();
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
I_XMMS_Off (void)
|
|
|
|
{
|
|
|
|
musEnabled = false;
|
2001-10-05 20:29:55 +00:00
|
|
|
I_XMMS_Kill ();
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
static void // Toggle Shuffling
|
2001-10-05 19:36:35 +00:00
|
|
|
I_XMMS_Shuffle (void)
|
|
|
|
{
|
2001-10-05 20:29:55 +00:00
|
|
|
int shuf;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
|
|
|
// for some reason, it reports shuffle wrong,
|
|
|
|
// probably because it relies on a timer that doesn't time out straight
|
|
|
|
// after change, and before the check
|
|
|
|
|
|
|
|
// SO, we check before, and assuming it works, we know that it will be the
|
|
|
|
// opposite of what it _WAS_, if you get my meaning :/
|
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
shuf = xmms_remote_is_shuffle (sessionNo);
|
|
|
|
xmms_remote_toggle_shuffle (sessionNo);
|
2004-02-07 05:35:15 +00:00
|
|
|
if (shuf == 1) {
|
2001-10-05 20:29:55 +00:00
|
|
|
Sys_Printf ("XMMSAudio: Shuffling Disabled\n");
|
2004-02-07 05:35:15 +00:00
|
|
|
} else if (shuf == 0) {
|
2001-10-05 20:29:55 +00:00
|
|
|
Sys_Printf ("XMMSAudio: Shuffling Enabled\n");
|
2004-02-07 05:35:15 +00:00
|
|
|
}
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
static void // toggles playlist repeating
|
2001-10-05 19:36:35 +00:00
|
|
|
I_XMMS_Repeat (void)
|
|
|
|
{
|
2004-02-07 05:35:15 +00:00
|
|
|
// Similar situation as with I_XMMS_Shuffle() -- same code too :)
|
2001-10-05 20:29:55 +00:00
|
|
|
int rep;
|
2001-10-05 19:36:35 +00:00
|
|
|
|
2001-10-05 20:29:55 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
2004-02-07 05:35:15 +00:00
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
rep = xmms_remote_is_repeat (sessionNo);
|
|
|
|
xmms_remote_toggle_repeat (sessionNo);
|
2004-02-07 05:35:15 +00:00
|
|
|
if (rep == 1) {
|
2001-10-05 20:29:55 +00:00
|
|
|
Sys_Printf ("XMMSAudio: Repeat Disabled\n");
|
2004-02-07 05:35:15 +00:00
|
|
|
} else if (rep == 0) {
|
2001-10-05 20:29:55 +00:00
|
|
|
Sys_Printf ("XMMSAudio: Repeat Enabled\n");
|
2004-02-07 05:35:15 +00:00
|
|
|
}
|
2001-10-05 19:36:35 +00:00
|
|
|
}
|
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
static void // sets playlist position
|
2001-10-12 19:26:56 +00:00
|
|
|
I_XMMS_Pos (int track)
|
|
|
|
{
|
2004-02-07 05:35:15 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
|
|
|
if (track < 0)
|
|
|
|
return; // -ve track numbers are dumb
|
|
|
|
xmms_remote_set_playlist_pos (sessionNo, track);
|
2001-10-15 17:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void // returns info about track playing and list progress
|
|
|
|
I_XMMS_Info (void) // this is untested with really long tracks, prolly works
|
|
|
|
{
|
2004-02-07 05:35:15 +00:00
|
|
|
int pos;
|
|
|
|
char *title;
|
2002-01-10 21:22:51 +00:00
|
|
|
unsigned int ctime; // -ve times are dumb, will this help ?
|
|
|
|
unsigned int cmin; // current no of mins
|
2004-02-07 05:35:15 +00:00
|
|
|
byte csecs; // current no of secs
|
2002-01-10 21:22:51 +00:00
|
|
|
unsigned int ttime; // total track time
|
|
|
|
unsigned int tmin; // total no of mins
|
2004-02-07 05:35:15 +00:00
|
|
|
byte tsecs; // total no of secs
|
2002-01-10 21:22:51 +00:00
|
|
|
unsigned int len; // playlist length
|
2001-10-15 17:37:05 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
if (!musEnabled)
|
|
|
|
return;
|
|
|
|
I_XMMS_Running ();
|
2001-10-15 17:37:05 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
pos = xmms_remote_get_playlist_pos (sessionNo); // get playlist position
|
|
|
|
len = xmms_remote_get_playlist_length (sessionNo); // playlist length
|
|
|
|
title = xmms_remote_get_playlist_title (sessionNo, pos); // get track title
|
|
|
|
ctime = xmms_remote_get_output_time (sessionNo); // get track elapsed time
|
|
|
|
ttime = xmms_remote_get_playlist_time (sessionNo, pos);
|
2012-05-21 23:23:22 +00:00
|
|
|
|
|
|
|
// The time returned by xmms_remote_get_output_time is in milliseconds
|
2001-10-15 17:37:05 +00:00
|
|
|
// elapsed, so, divide by (60*1000) to get mins (its an int, no decimals)
|
|
|
|
// and divide by 1000 mod 60 to get seconds. its a byte, no decimals too.
|
2004-02-07 05:35:15 +00:00
|
|
|
cmin = ctime / 60000;
|
|
|
|
csecs = ctime / 1000 % 60;
|
2001-10-15 17:37:05 +00:00
|
|
|
|
2004-02-07 05:35:15 +00:00
|
|
|
tmin = ttime / 60000;
|
|
|
|
tsecs = ttime / 1000 % 60;
|
2001-10-15 17:37:05 +00:00
|
|
|
|
|
|
|
// tell the user.
|
2004-02-07 05:35:15 +00:00
|
|
|
Sys_Printf ("XMMS: %d/%d %s %d:%02d/%d:%02d\n",
|
|
|
|
pos, len, title, cmin, csecs, tmin, tsecs);
|
2001-10-15 17:41:53 +00:00
|
|
|
free (title);
|
2001-10-12 19:26:56 +00:00
|
|
|
}
|
|
|
|
|
2001-10-05 19:36:35 +00:00
|
|
|
static void
|
|
|
|
I_XMMS_f (void)
|
|
|
|
{
|
|
|
|
const char *command;
|
|
|
|
|
|
|
|
if (Cmd_Argc () < 2)
|
|
|
|
return;
|
|
|
|
command = Cmd_Argv (1);
|
|
|
|
|
|
|
|
if (strequal (command, "play")) {
|
2001-10-12 23:14:59 +00:00
|
|
|
I_XMMS_Play ((atoi (Cmd_Argv (2)) -1), 0);
|
2001-10-05 19:36:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "on")) {
|
|
|
|
I_XMMS_On ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "off")) {
|
|
|
|
I_XMMS_Off ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "stop")) {
|
|
|
|
I_XMMS_Stop ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "pause")) {
|
|
|
|
I_XMMS_Pause ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "resume")) {
|
|
|
|
I_XMMS_Resume ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "next")) {
|
|
|
|
I_XMMS_Next ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "prev")) {
|
|
|
|
I_XMMS_Prev ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "shuffle")) {
|
|
|
|
I_XMMS_Shuffle ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strequal (command, "repeat")) {
|
|
|
|
I_XMMS_Repeat ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-10-12 19:26:56 +00:00
|
|
|
if (strequal (command, "pos")) {
|
2001-10-12 23:14:59 +00:00
|
|
|
I_XMMS_Pos (atoi (Cmd_Argv (2)) - 1);
|
2001-10-12 19:26:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-10-15 17:37:05 +00:00
|
|
|
if (strequal (command, "info")) {
|
|
|
|
I_XMMS_Info ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-10-05 19:36:35 +00:00
|
|
|
if (strequal (command, "help")) {
|
|
|
|
Sys_Printf ("Try \"help xmms\".\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 08:34:57 +00:00
|
|
|
static general_funcs_t plugin_info_general_funcs = {
|
|
|
|
I_XMMS_Init,
|
|
|
|
I_XMMS_Shutdown,
|
|
|
|
};
|
|
|
|
|
|
|
|
static cd_funcs_t plugin_info_cd_funcs = {
|
2021-06-26 06:43:17 +00:00
|
|
|
0,
|
2004-01-20 08:34:57 +00:00
|
|
|
I_XMMS_f,
|
|
|
|
I_XMMS_Pause,
|
|
|
|
I_XMMS_Play,
|
|
|
|
I_XMMS_Resume,
|
|
|
|
I_XMMS_Update,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_funcs_t plugin_info_funcs = {
|
|
|
|
&plugin_info_general_funcs,
|
|
|
|
0,
|
|
|
|
&plugin_info_cd_funcs,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_data_t plugin_info_data = {
|
|
|
|
&plugin_info_general_data,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_t plugin_info = {
|
|
|
|
qfp_cd,
|
|
|
|
0,
|
|
|
|
QFPLUGIN_VERSION,
|
|
|
|
"0.1",
|
|
|
|
"Linux XMMS Audio output\n",
|
2004-02-07 05:35:15 +00:00
|
|
|
"Copyright (C) 2001 contributors of the QuakeForge project\n"
|
|
|
|
"Please see the file \"AUTHORS\" for a list of contributors\n",
|
2004-01-20 08:34:57 +00:00
|
|
|
&plugin_info_funcs,
|
|
|
|
&plugin_info_data,
|
|
|
|
};
|
2001-10-05 20:29:55 +00:00
|
|
|
|
2004-01-20 08:34:57 +00:00
|
|
|
PLUGIN_INFO (cd, xmms)
|
|
|
|
{
|
2001-10-05 19:36:35 +00:00
|
|
|
return &plugin_info;
|
|
|
|
}
|