1
0
Fork 0
Commit graph

50 commits

Author SHA1 Message Date
krcroft
eef8c51419 Address code-review comments (squash-me) 2020-03-04 05:11:40 +01:00
krcroft
1d123367a5 Use MixerObject's singleton-pattern to manage the channel 2020-03-04 05:11:40 +01:00
krcroft
91cd907c4e Migrate some members of the Player class to smart pointers
1. Moves the mutex and mixer channel members to unique pointers
2. Moves the trackFile to a weak pointer
3. Move member initialization to the class definition

This class still retains a raw *cd member, however fixing this
ripples up to the array of [26] CD images, and across more
code that generically deals with mount points; so this work
remains to do.
2020-03-04 05:11:40 +01:00
krcroft
c132263116 Add partial DAE support for compressed Redbook-compliant tracks 2020-02-18 18:54:41 +01:00
krcroft
8382eb0e7e
Reduce the track number's type to comply with MSCDEX 2020-02-07 00:23:36 -08:00
krcroft
4aa3311021
Refine types and sizes to more accurately reflect the values they hold
This allows for fewer casts, simpler math, and more readable code
in subsequent commits.
2020-02-07 00:22:40 -08:00
krcroft
0f37f30246 Remove ClearTracks() and fix ref-assignment 2020-01-07 19:46:32 +01:00
krcroft
cc7d6b6e43 Fix double-free in destructor of CDROM_Interface_Image
Unmounting single binary-file CDROM images would result in a
crash as flagged by @dreamer_ in issue #112, who noted that
multiple tracks point to the same TrackFile (track.file field).

During destruction, the pre-C++11 code used a temporary
`TrackFile* last` variable to store the currently deleted
track.file's value and only delete the next track.file if it's
not equal to `last`. The result of this is that only the
first-encountered track.file was deleted and all subsequent
and back-to-back duplicate track.file values were left as-is.

This commit replaces the Track object's 'file' member pointer
with a shared_ptr, which effectively does the same thing by
only deleting the last reference.

The shared_ptr simplifies some error-cases where we previously
had to delete the Track.file allocation, but can now simply
let the Track object go out-of-scope and let the shared_ptr
delete it's managed object (if it has one).
2020-01-07 19:46:32 +01:00
Patryk Obara
94b987b5b5 Update MSF conversion functions
All usecases, that required these functions to pass 3 values separately
are now gone, we can simply pass/return a struct now.
2019-12-18 22:31:19 +01:00
Patryk Obara
f66a4f5416 Fix a number of effc++ warnings 2019-12-18 22:31:19 +01:00
Patryk Obara
d035c2cbd9 Move GetMountType to dos_mscdex file
This was the only user of this function.
2019-12-18 22:31:19 +01:00
Patryk Obara
28dd59e03e Introduce MountType enum for CDROM_GetMountType 2019-12-18 22:31:19 +01:00
Patryk Obara
f82a0a46da Remove dead code for force selecting CD drive 2019-12-18 22:31:19 +01:00
Patryk Obara
ac4411389b Remove CDROM_USE_SDL enum value 2019-12-18 22:31:19 +01:00
Patryk Obara
e1286efca9 Remove SDL_cdrom 1.2 based CD-ROM interfaces
This removes a feature of mounting physical CD-ROMs in DOSBox.

SDL 2.0 removed SDL_cdrom from supported libraries, so to bring this
code back, either the functionality will need to be reimplemented or
SDL_cdrom code modernized for SDL 2.0, and bundled with the repo (the
same way SDL_sound is already bundled).
2019-12-18 22:31:19 +01:00
Patryk Obara
ddda555854 Remove MCI, DX, and DIO CD-ROM interfaces
Also, remove all traces of these interfaces from user manual (README
file) and man page (docs/dosbox.1).

MCI (Media Control Interface) was a primary Windows interface. Code
comments and documentation claimed, that it's only for "NT, 2000, XP"
but the code was enabled for Windows 2000 or later (version > 4.0).

DX (Digital audio eXtraction (?)) could be forced on any Windows with
autodetection working only on Vista and Windows 7 (code was disabled for
Windows 8 or later - probably unintentionally).

DIO used DeviceIoControl interface and Windows-specific ioctl calls.

All 3 interfaces depend on SDL and SDL_cdrom functionality to work.
SDL_cdrom 1.2 implementation uses MCI on Windows to provide the same
functionality.
2019-12-14 03:35:27 +01:00
Patryk Obara
e43f83a68a Remove ASPI CD-ROM interface
ASPI was supported by Microsoft only for Windows 95, 98 and, ME.
Adaptec supported this interface going forward for Windows NT, 2000,
and XP (32-bit only).
2019-12-09 21:36:27 +01:00
Patryk Obara
d82766930f Reformat the enum with CD-ROM interfaces 2019-12-09 21:36:27 +01:00
Patryk Obara
5f9ac5eeab Remove code ifdefed for OS/2
Cleanup before replacing SDL1.2 with SDL2.

OS/2 support was introduced in DOSBox in March 2006.  OS/2 reached EOL
in December 2006.

As of 2019, OS/2 is being continued by proprietary 32-bit only ArcaOS,
although there is no official SDL2 support, despite pledges from SDL2
maintainers.
2019-12-09 16:27:11 +01:00
krcroft
eaeb001b17 Play into subsequent track(s) if playback length exceeds the the current track
Issue reported by Dagar and Pr3tty F1y, and confirmed as a bug by ripsaw8080.
Thank you!

This fixes the GoG release of Betrayal at Krondor which (either due to CD mastering
issues or a faulty rip), requests playback of a given track at the tail end
of the prior track.

In debugging and performing this fix, many debug messages were improved as well
as making some small small code adjustments, such as using iterators to point to
individual tracks (track->attribute) instead of using the tracks array
(tracks[track -1].attribute).
2019-11-24 17:34:54 +01:00
krcroft
d1a6f373cb Refactor CD-DA flow by removing intermediate buffers and loops
Thanks to @ripsaw8080 for insight into CD-DA channel mapping,
@hail-to-the-ryzen for testing and flagging a position-tracking bug,
and @dreamer_ for guidance and code review.

The CD-DA volume and channel mapping loops were moved to generic mixer
calls and no longer require a pre-processing loop:
 - Application-controlled CD-DA volume adjustment is now applied using
   an existing mixer volume scalar that was previously unused by the
   CD-DA code.
 - Mapping of CD-DA left and right channels is now applied at the tail
   end of the mixer's sample ingest sequence.

The following have been removed:
 - The CD-DA callback chunk-wise circular buffer
 - The decode buffers in the Opus and MP3 decoders
 - The decode buffer and conversion buffers in SDL_Sound
These removals and API changes allow the image player's buffer
to be passed-through ultimately to the audio codec, skipping multiple
intermediate buffers.
2019-11-12 08:16:53 +01:00
krcroft
edad78b5e0 Adapt and improve audio-handling in the CDROM sources
Runtime improvements:

- Replaces the existing audio callback routine with an efficient chunked
  circular-buffer audio reader
- Replaces assumptions that all audio tracks are 44.1 kHz & stereo.
  The mixer is now fed data at the actual compressed track's rate and
  channel count
- Eliminates all SDL locks in the audio code in favour of mixer state
  control
- Queries the codec for track-length instead of using hundreds of
  iterative decimating seeks to determine track length (loading
  a 99-track CUE now takes 0.1 user-seconds versus 3+ seconds
  previously)
- Seeks are performed within the already-decoded buffer (for all
  codecs) instead of discarding and re-running the decode sequence
- SDL_Sound's buffer-size is now set once and never resized, which
  eliminates repeated re-malloc'ing in the library
- Only one seek is performed per-playback sequence followed by
  sequential decodes, similar to a physical CDROM (The baseline dosbox
  performs a seek for every 2352-bytes of uncompressed audio)
- The DOSBox mixer is now only active during playback sequences and
  fully dormant otherwise (baseline dosbox instead performs hundreds of
  calls/second with empty data)
- When using Opus audio tracks, and if your dosbox.conf [mixer]
  rate=48000, then you will (very likely) achieve sample-exact
  unadulterated pass-through along your entire audio chain from the
  decoder, to DOSBox, to your operating system's software mixer,
  to your sound card driver, to your sound card, to your speakers,
  or to your digital receiver / USB speakers/headphones / or HDMI
  TV/screen.  This is because almost all modern hardware DACs use
  a native sample rate of 48000

Source-level maintenance improvements:

- It strips all pre-processor #ifdef branching for SDL_Sound from
  the code
- Fixes all codec compiler warnings (in the modified files); builds
  have been tested with GCC 4 to 10, Clang 6 to 10, and MSVC 14
- Tested on Linux, macOS (Xcode), and Windows (MinGW MSYS 1.0)
  operating systems
- Tested on i386, x86_64, ARM, and PowerPC (big-endian) architectures
2019-11-06 05:45:42 +01:00
Patryk Obara
fce61e33bb Implement frames/MSF conversion as functions
Macros FRAMES_TO_MSF and MSF_TO_FRAMES come from SDL_cdrom library.
SDL_cdrom was removed from SDL2 and these macros are used also in code
not directly related to SDL_cdrom library, so a replacement is needed.

Turns out output pointer type is different on Windows (int*) than it is on
Linux (unsigned char*); given choice between using void* for parameters and
a template function, I prefer template.
2019-11-02 19:29:03 +01:00
Peter Veenstra
1fbaff47fc Update year and address of FSF
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4183
2019-01-25 14:09:58 +00:00
Peter Veenstra
5bb10db88b Time keeps on ticking
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4109
2018-05-29 12:58:58 +00:00
Peter Veenstra
6cf39c1fc6 Years update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4021
2017-05-30 11:35:08 +00:00
Peter Veenstra
0f4c92ca32 Year update.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3878
2015-01-06 14:40:32 +00:00
Peter Veenstra
2fea508f7f Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3812
2013-01-15 09:03:13 +00:00
Peter Veenstra
999f33de27 Update year. Remove CVS tags
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3700
2011-04-26 09:34:55 +00:00
Peter Veenstra
8c29440d39 Add audio volume control for mscdex. Implemented it in images and win32ioctl. Others are still open. Thanks ripsaw.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3631
2010-08-07 18:32:39 +00:00
Sebastian Strohhäcker
1bcab407ae fix cdrom ioctl raw sector reading;
add mci cd audio functionality to cdrom ioctl interface;
add direct audio extraction functionality to cdrom ioctl interface


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3233
2008-11-06 19:31:21 +00:00
Peter Veenstra
0382a13bd3 Add basic support for audio cds only when dealing with images.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2982
2007-08-22 11:54:35 +00:00
Peter Veenstra
a5ac3216ba Some more const stuff. Silences a few warnings and removes a few casts. Update description of dss.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2886
2007-06-14 08:23:46 +00:00
Peter Veenstra
8c6d24bb61 making it an abc didn't work somehow.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2882
2007-06-12 19:32:34 +00:00
Peter Veenstra
a4d1439cce Add virtual destructor.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2880
2007-06-12 19:11:38 +00:00
Peter Veenstra
2c3ae52a79 os2 cdrom support
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2393
2005-11-25 19:15:12 +00:00
Peter Veenstra
62ad4ff475 Made it gcc2.95 friendly. Fix drivelabels on iso's. Fix Various stability issues with images
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2016
2004-10-05 19:55:03 +00:00
Sjoerd van der Berg
805187b0eb Use new mixer code for cd image audio
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1915
2004-08-23 09:22:23 +00:00
Peter Veenstra
02ff2737d7 Add Patch 1001897 by Martin. Disabled modem and ipx networking by default as they depend on libraries not everybody may have. Reduces alarmed firewall people and is nicer on unix hosts as port 23 is a bit tricky
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1904
2004-08-13 19:43:02 +00:00
Ulf Wohlers
c11d895fd4 improved aspi support (thanx SaPu)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1802
2004-05-19 11:44:48 +00:00
Ulf Wohlers
3001a346b2 made interface destructors virtual
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1656
2004-02-03 14:59:58 +00:00
Peter Veenstra
3e170dbdcf Added patch 884060 from Martin Battig
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1607
2004-01-27 20:23:13 +00:00
Ulf Wohlers
640e059254 Removed HostPt in ReadSector
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1132
2003-07-14 11:35:06 +00:00
Ulf Wohlers
336e693b61 Added support for reading volume labels
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@957
2003-04-23 12:07:53 +00:00
Ulf Wohlers
eee39b3127 sdl.h ->SDL.h
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@819
2003-03-27 22:02:47 +00:00
Ulf Wohlers
57d5d97852 default cdrom interface now sdl
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@812
2003-03-27 21:15:53 +00:00
Ulf Wohlers
02934f9676 Removed scsi-3 commands
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@782
2003-03-21 14:25:32 +00:00
Ulf Wohlers
a7104cb358 fixed wrong audio cd selection (multiple cdroms)
set the GetMediaTrayStatus parameters to more common values.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@781
2003-03-20 17:56:54 +00:00
Ulf Wohlers
6558efe97e Improved ioctl support
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@723
2003-03-06 14:29:43 +00:00
Ulf Wohlers
cfd4de316e cdrom interfaces
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@717
2003-03-06 13:34:27 +00:00