mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Port only distinct new feature work
This commit is contained in:
@@ -12,8 +12,10 @@
|
|||||||
| --- | ------ |
|
| --- | ------ |
|
||||||
| **F1** | Open Settings Window |
|
| **F1** | Open Settings Window |
|
||||||
| **F2** | Load New Image |
|
| **F2** | Load New Image |
|
||||||
|
| **S** | Save Track(s) |
|
||||||
| **Space** | Toggle Play / Pause |
|
| **Space** | Toggle Play / Pause |
|
||||||
| **Esc** | Stop Playback |
|
| **Esc** | Stop Playback |
|
||||||
|
| **~** | Eject |
|
||||||
| **→** | Next Track |
|
| **→** | Next Track |
|
||||||
| **←** | Previous Track |
|
| **←** | Previous Track |
|
||||||
| **]** | Next Index |
|
| **]** | Next Index |
|
||||||
@@ -25,6 +27,10 @@
|
|||||||
| **M** | Mute |
|
| **M** | Mute |
|
||||||
| **E** | Toggle Emphasis |
|
| **E** | Toggle Emphasis |
|
||||||
|
|
||||||
|
For Save Track(s):
|
||||||
|
- Holding no modifying keys will prompt to save the current track
|
||||||
|
- Holding **Shift** will prompt to save all tracks (including hidden)
|
||||||
|
|
||||||
For both Volume Up and Volume Down:
|
For both Volume Up and Volume Down:
|
||||||
- Holding **Ctrl** will move in increments of 2
|
- Holding **Ctrl** will move in increments of 2
|
||||||
- Holding **Shift** will move in increments of 5
|
- Holding **Shift** will move in increments of 5
|
||||||
|
|||||||
@@ -40,6 +40,23 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
PlayerView?.ViewModel?.ExecuteLoad();
|
PlayerView?.ViewModel?.ExecuteLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save track(s)
|
||||||
|
else if(e.Key == App.Settings.SaveTrackKey)
|
||||||
|
{
|
||||||
|
if(PlayerView?.ViewModel == null || !PlayerView.ViewModel.Initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var dialog = new OpenFolderDialog();
|
||||||
|
string path = await dialog.ShowAsync(App.MainWindow);
|
||||||
|
if(string.IsNullOrWhiteSpace(path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(e.KeyModifiers.HasFlag(KeyModifiers.Shift))
|
||||||
|
PlayerView.ViewModel.ExtractAllTracksToWav(path);
|
||||||
|
else
|
||||||
|
PlayerView.ViewModel.ExtractSingleTrackToWav((uint)PlayerView.ViewModel.CurrentTrackNumber, path);
|
||||||
|
}
|
||||||
|
|
||||||
// Toggle playback
|
// Toggle playback
|
||||||
else if(e.Key == App.Settings.TogglePlaybackKey || e.Key == Key.MediaPlayPause)
|
else if(e.Key == App.Settings.TogglePlaybackKey || e.Key == Key.MediaPlayPause)
|
||||||
{
|
{
|
||||||
@@ -52,6 +69,12 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
PlayerView?.ViewModel?.ExecuteStop();
|
PlayerView?.ViewModel?.ExecuteStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Eject
|
||||||
|
else if(e.Key == App.Settings.EjectKey)
|
||||||
|
{
|
||||||
|
PlayerView?.ViewModel?.ExecuteEject();
|
||||||
|
}
|
||||||
|
|
||||||
// Next Track
|
// Next Track
|
||||||
else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack)
|
else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,11 +6,9 @@ using System.Linq;
|
|||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Platform;
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using RedBookPlayer.Models;
|
using RedBookPlayer.Models;
|
||||||
@@ -193,6 +191,15 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _dataPlayback, value);
|
private set => this.RaiseAndSetIfChanged(ref _dataPlayback, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the repeat mode
|
||||||
|
/// </summary>
|
||||||
|
public RepeatMode RepeatMode
|
||||||
|
{
|
||||||
|
get => _repeatMode;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _repeatMode, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if de-emphasis should be applied
|
/// Indicates if de-emphasis should be applied
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -214,6 +221,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
private PlayerState _playerState;
|
private PlayerState _playerState;
|
||||||
private DataPlayback _dataPlayback;
|
private DataPlayback _dataPlayback;
|
||||||
|
private RepeatMode _repeatMode;
|
||||||
private bool _applyDeEmphasis;
|
private bool _applyDeEmphasis;
|
||||||
private int _volume;
|
private int _volume;
|
||||||
|
|
||||||
@@ -250,6 +258,11 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveCommand<Unit, Unit> StopCommand { get; }
|
public ReactiveCommand<Unit, Unit> StopCommand { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command for ejecting the current disc
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveCommand<Unit, Unit> EjectCommand { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for moving to the next track
|
/// Command for moving to the next track
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -334,6 +347,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
PauseCommand = ReactiveCommand.Create(ExecutePause);
|
PauseCommand = ReactiveCommand.Create(ExecutePause);
|
||||||
TogglePlayPauseCommand = ReactiveCommand.Create(ExecuteTogglePlayPause);
|
TogglePlayPauseCommand = ReactiveCommand.Create(ExecuteTogglePlayPause);
|
||||||
StopCommand = ReactiveCommand.Create(ExecuteStop);
|
StopCommand = ReactiveCommand.Create(ExecuteStop);
|
||||||
|
EjectCommand = ReactiveCommand.Create(ExecuteEject);
|
||||||
NextTrackCommand = ReactiveCommand.Create(ExecuteNextTrack);
|
NextTrackCommand = ReactiveCommand.Create(ExecuteNextTrack);
|
||||||
PreviousTrackCommand = ReactiveCommand.Create(ExecutePreviousTrack);
|
PreviousTrackCommand = ReactiveCommand.Create(ExecutePreviousTrack);
|
||||||
NextIndexCommand = ReactiveCommand.Create(ExecuteNextIndex);
|
NextIndexCommand = ReactiveCommand.Create(ExecuteNextIndex);
|
||||||
@@ -359,15 +373,16 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Path to the disc image</param>
|
/// <param name="path">Path to the disc image</param>
|
||||||
/// <param name="options">Options to pass to the optical disc factory</param>
|
/// <param name="options">Options to pass to the optical disc factory</param>
|
||||||
|
/// <param name="repeatMode">RepeatMode for sound output</param>
|
||||||
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
||||||
public void Init(string path, OpticalDiscOptions options, bool autoPlay)
|
public void Init(string path, OpticalDiscOptions options, RepeatMode repeatMode, bool autoPlay)
|
||||||
{
|
{
|
||||||
// Stop current playback, if necessary
|
// Stop current playback, if necessary
|
||||||
if(PlayerState != PlayerState.NoDisc)
|
if(PlayerState != PlayerState.NoDisc)
|
||||||
ExecuteStop();
|
ExecuteStop();
|
||||||
|
|
||||||
// Attempt to initialize Player
|
// Attempt to initialize Player
|
||||||
_player.Init(path, options, autoPlay);
|
_player.Init(path, options, repeatMode, autoPlay);
|
||||||
if(_player.Initialized)
|
if(_player.Initialized)
|
||||||
{
|
{
|
||||||
_player.PropertyChanged += PlayerStateChanged;
|
_player.PropertyChanged += PlayerStateChanged;
|
||||||
@@ -397,6 +412,11 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ExecuteStop() => _player?.Stop();
|
public void ExecuteStop() => _player?.Stop();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Eject the currently loaded disc
|
||||||
|
/// </summary>
|
||||||
|
public void ExecuteEject() => _player?.Eject();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move to the next playable track
|
/// Move to the next playable track
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -578,13 +598,14 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
DataPlayback = App.Settings.DataPlayback,
|
DataPlayback = App.Settings.DataPlayback,
|
||||||
GenerateMissingToc = App.Settings.GenerateMissingTOC,
|
GenerateMissingToc = App.Settings.GenerateMissingTOC,
|
||||||
LoadHiddenTracks = App.Settings.PlayHiddenTracks,
|
LoadHiddenTracks = App.Settings.PlayHiddenTracks,
|
||||||
|
SessionHandling = App.Settings.SessionHandling,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensure the context and view model are set
|
// Ensure the context and view model are set
|
||||||
App.PlayerView.DataContext = this;
|
App.PlayerView.DataContext = this;
|
||||||
App.PlayerView.ViewModel = this;
|
App.PlayerView.ViewModel = this;
|
||||||
|
|
||||||
Init(path, options, App.Settings.AutoPlay);
|
Init(path, options, App.Settings.RepeatMode, App.Settings.AutoPlay);
|
||||||
if(Initialized)
|
if(Initialized)
|
||||||
App.MainWindow.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
App.MainWindow.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
||||||
|
|
||||||
@@ -599,8 +620,23 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
{
|
{
|
||||||
SetDataPlayback(App.Settings.DataPlayback);
|
SetDataPlayback(App.Settings.DataPlayback);
|
||||||
SetLoadHiddenTracks(App.Settings.PlayHiddenTracks);
|
SetLoadHiddenTracks(App.Settings.PlayHiddenTracks);
|
||||||
|
SetRepeatMode(App.Settings.RepeatMode);
|
||||||
|
SetSessionHandling(App.Settings.SessionHandling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract a single track from the image to WAV
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trackNumber"></param>
|
||||||
|
/// <param name="outputDirectory">Output path to write data to</param
|
||||||
|
public void ExtractSingleTrackToWav(uint trackNumber, string outputDirectory) => _player?.ExtractSingleTrackToWav(trackNumber, outputDirectory);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract all tracks from the image to WAV
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="outputDirectory">Output path to write data to</param
|
||||||
|
public void ExtractAllTracksToWav(string outputDirectory) => _player?.ExtractAllTracksToWav(outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set data playback method [CompactDisc only]
|
/// Set data playback method [CompactDisc only]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -613,6 +649,18 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// <param name="load">True to enable loading hidden tracks, false otherwise</param>
|
/// <param name="load">True to enable loading hidden tracks, false otherwise</param>
|
||||||
public void SetLoadHiddenTracks(bool load) => _player?.SetLoadHiddenTracks(load);
|
public void SetLoadHiddenTracks(bool load) => _player?.SetLoadHiddenTracks(load);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set repeat mode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="repeatMode">New repeat mode value</param>
|
||||||
|
public void SetRepeatMode(RepeatMode repeatMode) => _player?.SetRepeatMode(repeatMode);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set session handling
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sessionHandling">New session handling value</param>
|
||||||
|
public void SetSessionHandling(SessionHandling sessionHandling) => _player?.SetSessionHandling(sessionHandling);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate the digit string to be interpreted by the frontend
|
/// Generate the digit string to be interpreted by the frontend
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -754,6 +802,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
|
|
||||||
CurrentTrackNumber = _player.CurrentTrackNumber;
|
CurrentTrackNumber = _player.CurrentTrackNumber;
|
||||||
CurrentTrackIndex = _player.CurrentTrackIndex;
|
CurrentTrackIndex = _player.CurrentTrackIndex;
|
||||||
|
CurrentTrackSession = _player.CurrentTrackSession;
|
||||||
CurrentSector = _player.CurrentSector;
|
CurrentSector = _player.CurrentSector;
|
||||||
SectionStartSector = _player.SectionStartSector;
|
SectionStartSector = _player.SectionStartSector;
|
||||||
|
|
||||||
@@ -766,6 +815,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
|
|
||||||
PlayerState = _player.PlayerState;
|
PlayerState = _player.PlayerState;
|
||||||
DataPlayback = _player.DataPlayback;
|
DataPlayback = _player.DataPlayback;
|
||||||
|
RepeatMode = _player.RepeatMode;
|
||||||
ApplyDeEmphasis = _player.ApplyDeEmphasis;
|
ApplyDeEmphasis = _player.ApplyDeEmphasis;
|
||||||
Volume = _player.Volume;
|
Volume = _player.Volume;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,18 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<DataPlayback> DataPlaybackValues => GenerateDataPlaybackList();
|
public List<DataPlayback> DataPlaybackValues => GenerateDataPlaybackList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of all repeat mode values
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<RepeatMode> RepeatModeValues => GenerateRepeatModeList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of all session handling values
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<SessionHandling> SessionHandlingValues => GenerateSessionHandlingList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all themes
|
/// List of all themes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -57,6 +69,16 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DataPlayback DataPlayback { get; set; } = DataPlayback.Skip;
|
public DataPlayback DataPlayback { get; set; } = DataPlayback.Skip;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how to repeat tracks
|
||||||
|
/// </summary>
|
||||||
|
public RepeatMode RepeatMode { get; set; } = RepeatMode.All;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how to handle tracks on different sessions
|
||||||
|
/// </summary>
|
||||||
|
public SessionHandling SessionHandling { get; set; } = SessionHandling.FirstSessionOnly;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates the default playback volume
|
/// Indicates the default playback volume
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -102,6 +124,11 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Key LoadImageKey { get; set; } = Key.F2;
|
public Key LoadImageKey { get; set; } = Key.F2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Key assigned to save the current track or all tracks
|
||||||
|
/// </summary>
|
||||||
|
public Key SaveTrackKey { get; set; } = Key.S;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Key assigned to toggle play and pause
|
/// Key assigned to toggle play and pause
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -253,6 +280,16 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private List<Key> GenerateKeyList() => Enum.GetValues(typeof(Key)).Cast<Key>().ToList();
|
private List<Key> GenerateKeyList() => Enum.GetValues(typeof(Key)).Cast<Key>().ToList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate the list of RepeatMode values
|
||||||
|
/// </summary>
|
||||||
|
private List<RepeatMode> GenerateRepeatModeList() => Enum.GetValues(typeof(RepeatMode)).Cast<RepeatMode>().ToList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate the list of SessionHandling values
|
||||||
|
/// </summary>
|
||||||
|
private List<SessionHandling> GenerateSessionHandlingList() => Enum.GetValues(typeof(SessionHandling)).Cast<SessionHandling>().ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate the list of valid themes
|
/// Generate the list of valid themes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -30,6 +30,16 @@
|
|||||||
<ComboBox Grid.Row="0" Grid.Column="1" Name="DataPlayback" Margin="8,0,0,0" Width="120"
|
<ComboBox Grid.Row="0" Grid.Column="1" Name="DataPlayback" Margin="8,0,0,0" Width="120"
|
||||||
Items="{Binding DataPlaybackValues}" SelectedItem="{Binding DataPlayback, Mode=TwoWay}" />
|
Items="{Binding DataPlaybackValues}" SelectedItem="{Binding DataPlayback, Mode=TwoWay}" />
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
<WrapPanel Margin="0,0,0,16">
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="0" Width="120">Session Handling</TextBlock>
|
||||||
|
<ComboBox Grid.Row="0" Grid.Column="1" Name="SessionHandling" Margin="8,0,0,0" Width="120"
|
||||||
|
Items="{Binding SessionHandlingValues}" SelectedItem="{Binding SessionHandling, Mode=TwoWay}" />
|
||||||
|
</WrapPanel>
|
||||||
|
<WrapPanel Margin="0,0,0,16">
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="0" Width="120">Repeat Mode</TextBlock>
|
||||||
|
<ComboBox Grid.Row="0" Grid.Column="1" Name="RepeatMode" Margin="8,0,0,0" Width="120"
|
||||||
|
Items="{Binding RepeatModeValues}" SelectedItem="{Binding RepeatMode, Mode=TwoWay}" />
|
||||||
|
</WrapPanel>
|
||||||
<WrapPanel Margin="0,0,0,16">
|
<WrapPanel Margin="0,0,0,16">
|
||||||
<CheckBox IsChecked="{Binding GenerateMissingTOC}" Margin="0,0,8,0"/>
|
<CheckBox IsChecked="{Binding GenerateMissingTOC}" Margin="0,0,8,0"/>
|
||||||
<TextBlock VerticalAlignment="Center">Generate a TOC if the disc is missing one</TextBlock>
|
<TextBlock VerticalAlignment="Center">Generate a TOC if the disc is missing one</TextBlock>
|
||||||
@@ -78,6 +88,12 @@
|
|||||||
Items="{Binding KeyboardList}" SelectedItem="{Binding LoadImageKey, Mode=TwoWay}"
|
Items="{Binding KeyboardList}" SelectedItem="{Binding LoadImageKey, Mode=TwoWay}"
|
||||||
HorizontalAlignment="Right" Margin="8,0,0,0" Width="120"/>
|
HorizontalAlignment="Right" Margin="8,0,0,0" Width="120"/>
|
||||||
|
|
||||||
|
<!-- Save Track -->
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" Width="120">Save Track(s)</TextBlock>
|
||||||
|
<ComboBox Grid.Row="1" Grid.Column="1" Name="SaveTrackKeyBind"
|
||||||
|
Items="{Binding KeyboardList}" SelectedItem="{Binding SaveTrackKey, Mode=TwoWay}"
|
||||||
|
HorizontalAlignment="Right" Margin="8,0,0,0" Width="120"/>
|
||||||
|
|
||||||
<!-- Toggle Play/Pause -->
|
<!-- Toggle Play/Pause -->
|
||||||
<TextBlock Grid.Row="2" Grid.Column="0" Width="120">Toggle Play/Pause</TextBlock>
|
<TextBlock Grid.Row="2" Grid.Column="0" Width="120">Toggle Play/Pause</TextBlock>
|
||||||
<ComboBox Grid.Row="2" Grid.Column="1" Name="TogglePlaybackKeyBind"
|
<ComboBox Grid.Row="2" Grid.Column="1" Name="TogglePlaybackKeyBind"
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.CommonTypes.Structs;
|
using Aaru.CommonTypes.Structs;
|
||||||
using Aaru.Decoders.CD;
|
using Aaru.Decoders.CD;
|
||||||
using Aaru.Helpers;
|
using Aaru.Helpers;
|
||||||
|
using CSCore.Codecs.WAV;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using static Aaru.Decoders.CD.FullTOC;
|
using static Aaru.Decoders.CD.FullTOC;
|
||||||
|
|
||||||
@@ -69,7 +71,8 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
SetTrackFlags(track);
|
SetTrackFlags(track);
|
||||||
|
|
||||||
// If the track is playable, just return
|
// If the track is playable, just return
|
||||||
if(TrackType == TrackType.Audio || DataPlayback != DataPlayback.Skip)
|
if((TrackType == TrackType.Audio || DataPlayback != DataPlayback.Skip)
|
||||||
|
&& (SessionHandling == SessionHandling.AllSessions || track.TrackSession == 1))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -102,6 +105,7 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
|
|
||||||
TotalIndexes = cachedTrack.Indexes.Keys.Max();
|
TotalIndexes = cachedTrack.Indexes.Keys.Max();
|
||||||
CurrentTrackIndex = cachedTrack.Indexes.Keys.Min();
|
CurrentTrackIndex = cachedTrack.Indexes.Keys.Min();
|
||||||
|
CurrentTrackSession = cachedTrack.TrackSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +139,13 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override ushort CurrentTrackSession
|
||||||
|
{
|
||||||
|
get => _currentTrackSession;
|
||||||
|
protected set => this.RaiseAndSetIfChanged(ref _currentTrackSession, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override ulong CurrentSector
|
public override ulong CurrentSector
|
||||||
{
|
{
|
||||||
@@ -229,6 +240,11 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LoadHiddenTracks { get; set; } = false;
|
public bool LoadHiddenTracks { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how tracks on different session should be handled
|
||||||
|
/// </summary>
|
||||||
|
public SessionHandling SessionHandling { get; set; } = SessionHandling.AllSessions;
|
||||||
|
|
||||||
private bool _quadChannel;
|
private bool _quadChannel;
|
||||||
private bool _isDataTrack;
|
private bool _isDataTrack;
|
||||||
private bool _copyAllowed;
|
private bool _copyAllowed;
|
||||||
@@ -248,6 +264,11 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ushort _currentTrackIndex = 0;
|
private ushort _currentTrackIndex = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current track session
|
||||||
|
/// </summary>
|
||||||
|
private ushort _currentTrackSession = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current sector number
|
/// Current sector number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -274,6 +295,7 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
DataPlayback = options.DataPlayback;
|
DataPlayback = options.DataPlayback;
|
||||||
_generateMissingToc = options.GenerateMissingToc;
|
_generateMissingToc = options.GenerateMissingToc;
|
||||||
LoadHiddenTracks = options.LoadHiddenTracks;
|
LoadHiddenTracks = options.LoadHiddenTracks;
|
||||||
|
SessionHandling = options.SessionHandling;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -417,6 +439,44 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void ExtractTrackToWav(uint trackNumber, string outputDirectory)
|
||||||
|
{
|
||||||
|
if(_image == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get the track with that value, if possible
|
||||||
|
Track track = _image.Tracks.FirstOrDefault(t => t.TrackSequence == trackNumber);
|
||||||
|
|
||||||
|
// If the track isn't valid, we can't do anything
|
||||||
|
if(track == null || track.TrackType != TrackType.Audio)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Read in the track data to a buffer
|
||||||
|
uint length = (uint)(track.TrackEndSector - track.TrackStartSector);
|
||||||
|
byte[] buffer = _image.ReadSectors(track.TrackStartSector, length);
|
||||||
|
|
||||||
|
// Build the WAV output
|
||||||
|
string filename = Path.Combine(outputDirectory, $"Track {trackNumber.ToString().PadLeft(2, '0')}.wav");
|
||||||
|
using(WaveWriter waveWriter = new WaveWriter(filename, new CSCore.WaveFormat()))
|
||||||
|
{
|
||||||
|
// Write out to the file
|
||||||
|
waveWriter.Write(buffer, 0, buffer.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void ExtractAllTracksToWav(string outputDirectory)
|
||||||
|
{
|
||||||
|
if(_image == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach(Track track in _image.Tracks)
|
||||||
|
{
|
||||||
|
ExtractTrackToWav(track.TrackSequence, outputDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void LoadTrack(int trackNumber)
|
public override void LoadTrack(int trackNumber)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract ushort CurrentTrackIndex { get; protected set; }
|
public abstract ushort CurrentTrackIndex { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current track session
|
||||||
|
/// </summary>
|
||||||
|
public abstract ushort CurrentTrackSession { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current sector number
|
/// Current sector number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -122,6 +127,19 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract a track to WAV
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trackNumber">Track number to extract</param>
|
||||||
|
/// <param name="outputDirectory">Output path to write data to</param
|
||||||
|
public abstract void ExtractTrackToWav(uint trackNumber, string outputDirectory);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract all tracks to WAV
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="outputDirectory">Output path to write data to</param
|
||||||
|
public abstract void ExtractAllTracksToWav(string outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load the desired track, if possible
|
/// Load the desired track, if possible
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LoadHiddenTracks { get; set; } = false;
|
public bool LoadHiddenTracks { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how tracks on different session should be handled
|
||||||
|
/// </summary>
|
||||||
|
public SessionHandling SessionHandling { get; set; } = SessionHandling.AllSessions;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,4 +46,41 @@ namespace RedBookPlayer.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Playing,
|
Playing,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Playback repeat mode
|
||||||
|
/// </summary>
|
||||||
|
public enum RepeatMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No repeat
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repeat a single track
|
||||||
|
/// </summary>
|
||||||
|
Single,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repeat all tracks
|
||||||
|
/// </summary>
|
||||||
|
All,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine how to handle different sessions
|
||||||
|
/// </summary>
|
||||||
|
public enum SessionHandling
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Allow playing tracks from all sessions
|
||||||
|
/// </summary>
|
||||||
|
AllSessions = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Only play tracks from the first session
|
||||||
|
/// </summary>
|
||||||
|
FirstSessionOnly = 1,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -39,6 +39,15 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _currentTrackIndex, value);
|
private set => this.RaiseAndSetIfChanged(ref _currentTrackIndex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current track session
|
||||||
|
/// </summary>
|
||||||
|
public ushort CurrentTrackSession
|
||||||
|
{
|
||||||
|
get => _currentTrackSession;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _currentTrackSession, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current sector number
|
/// Current sector number
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -129,6 +138,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
|
|
||||||
private int _currentTrackNumber;
|
private int _currentTrackNumber;
|
||||||
private ushort _currentTrackIndex;
|
private ushort _currentTrackIndex;
|
||||||
|
private ushort _currentTrackSession;
|
||||||
private ulong _currentSector;
|
private ulong _currentSector;
|
||||||
private ulong _sectionStartSector;
|
private ulong _sectionStartSector;
|
||||||
|
|
||||||
@@ -160,6 +170,15 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _dataPlayback, value);
|
private set => this.RaiseAndSetIfChanged(ref _dataPlayback, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the repeat mode
|
||||||
|
/// </summary>
|
||||||
|
public RepeatMode RepeatMode
|
||||||
|
{
|
||||||
|
get => _repeatMode;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _repeatMode, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if de-emphasis should be applied
|
/// Indicates if de-emphasis should be applied
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -180,6 +199,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
|
|
||||||
private PlayerState _playerState;
|
private PlayerState _playerState;
|
||||||
private DataPlayback _dataPlayback;
|
private DataPlayback _dataPlayback;
|
||||||
|
private RepeatMode _repeatMode;
|
||||||
private bool _applyDeEmphasis;
|
private bool _applyDeEmphasis;
|
||||||
private int _volume;
|
private int _volume;
|
||||||
|
|
||||||
@@ -220,8 +240,9 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Path to the disc image</param>
|
/// <param name="path">Path to the disc image</param>
|
||||||
/// <param name="options">Options to pass to the optical disc factory</param>
|
/// <param name="options">Options to pass to the optical disc factory</param>
|
||||||
|
/// <param name="repeatMode">RepeatMode for sound output</param>
|
||||||
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
||||||
public void Init(string path, OpticalDiscOptions options, bool autoPlay)
|
public void Init(string path, OpticalDiscOptions options, RepeatMode repeatMode, bool autoPlay)
|
||||||
{
|
{
|
||||||
// Reset initialization
|
// Reset initialization
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
@@ -235,7 +256,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
_opticalDisc.PropertyChanged += OpticalDiscStateChanged;
|
_opticalDisc.PropertyChanged += OpticalDiscStateChanged;
|
||||||
|
|
||||||
// Initialize the sound output
|
// Initialize the sound output
|
||||||
_soundOutput.Init(_opticalDisc, autoPlay);
|
_soundOutput.Init(_opticalDisc, repeatMode, autoPlay);
|
||||||
if(_soundOutput == null || !_soundOutput.Initialized)
|
if(_soundOutput == null || !_soundOutput.Initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -323,6 +344,23 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
PlayerState = PlayerState.Stopped;
|
PlayerState = PlayerState.Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Eject the currently loaded disc
|
||||||
|
/// </summary>
|
||||||
|
public void Eject()
|
||||||
|
{
|
||||||
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
||||||
|
return;
|
||||||
|
else if(_soundOutput == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Stop();
|
||||||
|
_soundOutput.Eject();
|
||||||
|
_opticalDisc = null;
|
||||||
|
PlayerState = PlayerState.NoDisc;
|
||||||
|
Initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move to the next playable track
|
/// Move to the next playable track
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -493,6 +531,18 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract a single track from the image to WAV
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trackNumber"></param>
|
||||||
|
/// <param name="outputDirectory">Output path to write data to</param
|
||||||
|
public void ExtractSingleTrackToWav(uint trackNumber, string outputDirectory) => _opticalDisc?.ExtractTrackToWav(trackNumber, outputDirectory);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extract all tracks from the image to WAV
|
||||||
|
/// <param name="outputDirectory">Output path to write data to</param
|
||||||
|
public void ExtractAllTracksToWav(string outputDirectory) => _opticalDisc?.ExtractAllTracksToWav(outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set data playback method [CompactDisc only]
|
/// Set data playback method [CompactDisc only]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -513,6 +563,22 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
compactDisc.LoadHiddenTracks = load;
|
compactDisc.LoadHiddenTracks = load;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set repeat mode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="repeatMode">New repeat mode value</param>
|
||||||
|
public void SetRepeatMode(RepeatMode repeatMode) => _soundOutput?.SetRepeatMode(repeatMode);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the value for session handling [CompactDisc only]
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sessionHandling">New session handling value</param>
|
||||||
|
public void SetSessionHandling(SessionHandling sessionHandling)
|
||||||
|
{
|
||||||
|
if(_opticalDisc is CompactDisc compactDisc)
|
||||||
|
compactDisc.SessionHandling = sessionHandling;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the player from the current OpticalDisc
|
/// Update the player from the current OpticalDisc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -547,6 +613,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private void SoundOutputStateChanged(object sender, PropertyChangedEventArgs e)
|
private void SoundOutputStateChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
PlayerState = _soundOutput.PlayerState;
|
PlayerState = _soundOutput.PlayerState;
|
||||||
|
RepeatMode = _soundOutput.RepeatMode;
|
||||||
ApplyDeEmphasis = _soundOutput.ApplyDeEmphasis;
|
ApplyDeEmphasis = _soundOutput.ApplyDeEmphasis;
|
||||||
Volume = _soundOutput.Volume;
|
Volume = _soundOutput.Volume;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,15 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _playerState, value);
|
private set => this.RaiseAndSetIfChanged(ref _playerState, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the repeat mode
|
||||||
|
/// </summary>
|
||||||
|
public RepeatMode RepeatMode
|
||||||
|
{
|
||||||
|
get => _repeatMode;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _repeatMode, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if de-emphasis should be applied
|
/// Indicates if de-emphasis should be applied
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -60,6 +69,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
private PlayerState _playerState;
|
private PlayerState _playerState;
|
||||||
|
private RepeatMode _repeatMode;
|
||||||
private bool _applyDeEmphasis;
|
private bool _applyDeEmphasis;
|
||||||
private int _volume;
|
private int _volume;
|
||||||
|
|
||||||
@@ -117,8 +127,9 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// Initialize the output with a given image
|
/// Initialize the output with a given image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="opticalDisc">OpticalDisc to load from</param>
|
/// <param name="opticalDisc">OpticalDisc to load from</param>
|
||||||
|
/// <param name="repeatMode">RepeatMode for sound output</param>
|
||||||
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
||||||
public void Init(OpticalDiscBase opticalDisc, bool autoPlay)
|
public void Init(OpticalDiscBase opticalDisc, RepeatMode repeatMode, bool autoPlay)
|
||||||
{
|
{
|
||||||
// If we have an unusable disc, just return
|
// If we have an unusable disc, just return
|
||||||
if(opticalDisc == null || !opticalDisc.Initialized)
|
if(opticalDisc == null || !opticalDisc.Initialized)
|
||||||
@@ -137,6 +148,9 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
// Setup the audio output
|
// Setup the audio output
|
||||||
SetupAudio();
|
SetupAudio();
|
||||||
|
|
||||||
|
// Setup the repeat mode
|
||||||
|
RepeatMode = repeatMode;
|
||||||
|
|
||||||
// Initialize playback, if necessary
|
// Initialize playback, if necessary
|
||||||
if(autoPlay)
|
if(autoPlay)
|
||||||
_soundOut.Play();
|
_soundOut.Play();
|
||||||
@@ -149,6 +163,17 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
_source.Start();
|
_source.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset the current internal state
|
||||||
|
/// </summary>
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_soundOut.Stop();
|
||||||
|
_opticalDisc = null;
|
||||||
|
Initialized = false;
|
||||||
|
PlayerState = PlayerState.NoDisc;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fill the current byte buffer with playable data
|
/// Fill the current byte buffer with playable data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -189,6 +214,11 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
int currentTrack = _opticalDisc.CurrentTrackNumber;
|
int currentTrack = _opticalDisc.CurrentTrackNumber;
|
||||||
_opticalDisc.SetCurrentSector(_opticalDisc.CurrentSector + (ulong)(_currentSectorReadPosition / _opticalDisc.BytesPerSector));
|
_opticalDisc.SetCurrentSector(_opticalDisc.CurrentSector + (ulong)(_currentSectorReadPosition / _opticalDisc.BytesPerSector));
|
||||||
_currentSectorReadPosition %= _opticalDisc.BytesPerSector;
|
_currentSectorReadPosition %= _opticalDisc.BytesPerSector;
|
||||||
|
|
||||||
|
if(RepeatMode == RepeatMode.None && _opticalDisc.CurrentTrackNumber < currentTrack)
|
||||||
|
Stop();
|
||||||
|
else if(RepeatMode == RepeatMode.Single && _opticalDisc.CurrentTrackNumber != currentTrack)
|
||||||
|
_opticalDisc.LoadTrack(currentTrack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@@ -229,6 +259,11 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
PlayerState = PlayerState.Stopped;
|
PlayerState = PlayerState.Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Eject the currently loaded disc
|
||||||
|
/// </summary>
|
||||||
|
public void Eject() => Reset();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
@@ -239,6 +274,12 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// <param name="apply">New de-emphasis status</param>
|
/// <param name="apply">New de-emphasis status</param>
|
||||||
public void SetDeEmphasis(bool apply) => ApplyDeEmphasis = apply;
|
public void SetDeEmphasis(bool apply) => ApplyDeEmphasis = apply;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set repeat mode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="repeatMode">New repeat mode value</param>
|
||||||
|
public void SetRepeatMode(RepeatMode repeatMode) => RepeatMode = repeatMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the value for the volume
|
/// Set the value for the volume
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -253,8 +294,8 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// <param name="zeroSectorsAmount">Number of zeroed sectors to concatenate</param>
|
/// <param name="zeroSectorsAmount">Number of zeroed sectors to concatenate</param>
|
||||||
private void DetermineReadAmount(int count, out ulong sectorsToRead, out ulong zeroSectorsAmount)
|
private void DetermineReadAmount(int count, out ulong sectorsToRead, out ulong zeroSectorsAmount)
|
||||||
{
|
{
|
||||||
// Attempt to read 5 more sectors than requested
|
// Attempt to read 10 more sectors than requested
|
||||||
sectorsToRead = ((ulong)count / (ulong)_opticalDisc.BytesPerSector) + 5;
|
sectorsToRead = ((ulong)count / (ulong)_opticalDisc.BytesPerSector) + 10;
|
||||||
zeroSectorsAmount = 0;
|
zeroSectorsAmount = 0;
|
||||||
|
|
||||||
// Avoid overreads by padding with 0-byte data at the end
|
// Avoid overreads by padding with 0-byte data at the end
|
||||||
|
|||||||
Reference in New Issue
Block a user