Skip to content

Commit ddcb807

Browse files
committed
Do not hijack Null player, implement our own
1 parent 28c137a commit ddcb807

File tree

6 files changed

+67
-26
lines changed

6 files changed

+67
-26
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ adplay_SOURCES = adplay.cc output.cc output.h players.h defines.h
44

55
EXTRA_adplay_SOURCES = oss.cc oss.h null.h disk.cc disk.h esound.cc esound.h \
66
qsa.cc qsa.h sdl.cc sdl_driver.h alsa.cc alsa.h ao.cc ao.h getopt.c \
7-
getopt1.c getopt.h
7+
getopt1.c getopt.h diskraw.h
88

99
adplay_LDADD = $(drivers) $(adplug_LIBS) @ESD_LIBS@ @QSA_LIBS@ @SDL_LIBS@ \
1010
@ALSA_LIBS@ @AO_LIBS@ $(GETOPT_SOURCES)

src/adplay.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ static int decode_switches(int argc, char **argv)
324324
#endif
325325
else if(!strcmp(optarg, "rawout")) {
326326
cfg.emutype = Emu_Rawout;
327-
cfg.output = null;
328-
cfg.endless = false;
327+
cfg.endless = false; // endless output is almost never desired here
329328
}
330329

331330
else {
@@ -338,6 +337,10 @@ static int decode_switches(int argc, char **argv)
338337
}
339338
if (!cfg.loops) cfg.loops = 1;
340339

340+
if (cfg.emutype == Emu_Rawout) {
341+
cfg.output = diskraw; // output must be diskraw when Emu_Rawout is selected
342+
}
343+
341344
return optind;
342345
}
343346

@@ -434,6 +437,7 @@ int main(int argc, char **argv)
434437
int optind, i;
435438
const char *homedir;
436439
char *userdb = NULL;
440+
CDiskopl *dopl = 0;
437441

438442
// init
439443
program_name = argv[0];
@@ -549,7 +553,8 @@ int main(int argc, char **argv)
549553
break;
550554
#endif
551555
case Emu_Rawout:
552-
opl = new CDiskopl(cfg.device);
556+
dopl = new CDiskopl(cfg.device);
557+
opl = dopl;
553558
}
554559

555560
// init player
@@ -565,7 +570,7 @@ int main(int argc, char **argv)
565570
#endif
566571
#ifdef DRIVER_NULL
567572
case null:
568-
player = new NullOutput(opl);
573+
player = new NullOutput();
569574
break;
570575
#endif
571576
#ifdef DRIVER_DISK
@@ -600,6 +605,10 @@ int main(int argc, char **argv)
600605
cfg.buf_size);
601606
break;
602607
#endif
608+
case diskraw:
609+
player = new DiskRawWriter(dopl);
610+
dopl = NULL;
611+
break;
603612
default:
604613
message(MSG_ERROR, "output method not available");
605614
exit(EXIT_FAILURE);

src/diskraw.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* AdPlay/UNIX - OPL2 audio player
3+
* Copyright (C) 2001, 2002 Simon Peter <dn.tlp@gmx.net>
4+
*
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, or (at your option)
8+
* any later version.
9+
*
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.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program; if not, write to the Free Software Foundation,
17+
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18+
*/
19+
20+
#ifndef H_DISKRAW
21+
#define H_DISKRAW
22+
23+
#include "output.h"
24+
25+
/* pairs up to AdPlay CDiskopl */
26+
class DiskRawWriter: public Player
27+
{
28+
public:
29+
DiskRawWriter(CDiskopl *nopl)
30+
:opl(nopl)
31+
{ }
32+
33+
virtual void frame() {
34+
playing = p->update();
35+
opl->update(p);
36+
}
37+
38+
virtual Copl *get_opl()
39+
{ return opl; }
40+
41+
private:
42+
CDiskopl *opl;
43+
};
44+
45+
#endif

src/null.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,20 @@
2020
#ifndef H_NULL
2121
#define H_NULL
2222

23+
#include <adplug/silentopl.h>
2324
#include "output.h"
2425

2526
class NullOutput: public Player
2627
{
2728
public:
28-
NullOutput(Copl *nopl)
29-
:opl(nopl)
30-
{ }
31-
32-
virtual void frame() {
33-
playing = p->update();
34-
35-
CDiskopl *dopl = dynamic_cast<CDiskopl *>(opl);
36-
if (dopl != NULL) {
37-
dopl->update(p);
38-
}
39-
}
29+
virtual void frame()
30+
{ }
4031

4132
virtual Copl *get_opl()
42-
{ return opl; }
33+
{ return &opl; }
4334

4435
private:
45-
Copl *opl;
36+
CSilentopl opl;
4637
};
4738

4839
#endif

src/output.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <stdio.h>
2121
#include <adplug/emuopl.h>
2222
#include <adplug/kemuopl.h>
23-
#include <adplug/diskopl.h>
2423

2524
#include "output.h"
2625
#include "defines.h"
@@ -73,11 +72,6 @@ void EmuPlayer::frame()
7372
}
7473
i = MIN(towrite, (long)(minicnt / p->getrefresh() + 4) & ~3);
7574
opl->update((short *)pos, i);
76-
CDiskopl *dopl = dynamic_cast<CDiskopl *>(opl);
77-
if (dopl != NULL) {
78-
dopl->update(p);
79-
}
80-
8175
pos += i * getsampsize(); towrite -= i;
8276
i = (long)(p->getrefresh() * i);
8377
minicnt -= MAX(1, i);

src/players.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "config.h"
2929

3030
// Enumerate ALL outputs (regardless of availability)
31-
enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa};
31+
enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa, diskraw};
3232

3333
#define DEFAULT_DRIVER none
3434

@@ -88,4 +88,6 @@ enum Outputs {none, null, ao, oss, disk, esound, qsa, sdl, alsa};
8888
#define DEFAULT_DRIVER qsa
8989
#endif
9090

91+
#include "diskraw.h"
92+
9193
#endif

0 commit comments

Comments
 (0)