-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPlugin.pm
76 lines (54 loc) · 2.64 KB
/
Plugin.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package Plugins::DSDPlayer::Plugin;
use strict;
use base qw(Slim::Plugin::OPMLBased);
use Slim::Utils::Log;
use Slim::Utils::Prefs;
use Slim::Player::TranscodingHelper;
use Plugins::DSDPlayer::PlayerSettings;
my $prefs = preferences('plugin.playdsd');
my $log = Slim::Utils::Log->addLogCategory({
'category' => 'plugin.playdsd',
'defaultLevel' => 'WARN',
'description' => 'PLUGIN_DSDPLAYER',
});
sub initPlugin {
my $class = shift;
Plugins::DSDPlayer::PlayerSettings->new;
Slim::Control::Request::subscribe(\&initClientForDSD, [['client'],['new','reconnect']]);
}
sub setupTranscoder {
my $client = $_[0] || return;
my $usedop = $prefs->client($client)->get('usedop');
my $resample = $prefs->client($client)->get('resample') || "::::::";
my $gain = $prefs->client($client)->get('gain');
my $cmdTable = "[dsdplay] -R $resample " . '$START$ $END$ $RESAMPLE$ $FILE$';
$cmdTable .= " | [sox] -q -t flac - -t flac -C 0 - gain -l $gain" if $gain;
my $cmdTableDoP = "[dsdplay] -R $resample -u " . '$START$ $END$ $RESAMPLE$ $FILE$';
my $capabilities = { F => 'noArgs', T => 'START=-s %t', U => 'END=-e %v', D => 'RESAMPLE=-r %d' };
my $wvpxCmdTable = "[wvunpack] " . '$FILE$ $START$ $END$' . " --dff -o - | [dsdplay] -R $resample " . '$RESAMPLE$';
my $wvpxCmdTableDoP = "[wvunpack] " . '$FILE$ $START$ $END$' . " --dff -o - | [dsdplay] -u -R $resample " . '$RESAMPLE$';
my $wvpxCapabilities = { F => 'noArgs', T => 'START=--skip=%t', U => 'END=--until=%v', D => 'RESAMPLE=-r %d' };
my $dsf = 'dsf-flc-*-' . lc($client->macaddress);
my $dff = 'dff-flc-*-' . lc($client->macaddress);
my $wvpx = 'wvpx-flc-*-' . lc($client->macaddress);
if ($usedop) {
$Slim::Player::TranscodingHelper::commandTable{ $dsf } = $cmdTableDoP;
$Slim::Player::TranscodingHelper::capabilities{ $dsf } = $capabilities;
$Slim::Player::TranscodingHelper::commandTable{ $dff } = $cmdTableDoP;
$Slim::Player::TranscodingHelper::capabilities{ $dff } = $capabilities;
$Slim::Player::TranscodingHelper::commandTable{ $wvpx } = $wvpxCmdTableDoP;
$Slim::Player::TranscodingHelper::capabilities{ $wvpx } = $wvpxCapabilities;
} else {
$Slim::Player::TranscodingHelper::commandTable{ $dsf } = $cmdTable;
$Slim::Player::TranscodingHelper::capabilities{ $dsf } = $capabilities;
$Slim::Player::TranscodingHelper::commandTable{ $dff } = $cmdTable;
$Slim::Player::TranscodingHelper::capabilities{ $dff } = $capabilities;
$Slim::Player::TranscodingHelper::commandTable{ $wvpx } = $wvpxCmdTable;
$Slim::Player::TranscodingHelper::capabilities{ $wvpx } = $wvpxCapabilities;
}
}
sub initClientForDSD {
my $request = shift;
setupTranscoder($request->client());
}
1;