-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.pm
62 lines (40 loc) · 1.63 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
package Plugins::BS2B::Plugin;
use strict;
use base qw(Slim::Plugin::OPMLBased);
use Slim::Utils::Log;
use Slim::Utils::Prefs;
use Slim::Player::TranscodingHelper;
use Plugins::BS2B::PlayerSettings;
my $prefs = preferences('plugin.bs2b');
my $log = Slim::Utils::Log->addLogCategory({
'category' => 'plugin.bs2b',
'defaultLevel' => 'WARN',
'description' => 'PLUGIN_BS2B',
});
sub initPlugin {
my $class = shift;
Plugins::BS2B::PlayerSettings->new;
Slim::Control::Request::subscribe(\&initClient, [['client'],['new','reconnect']]);
}
sub setupTranscoder {
my $client = $_[0] || return;
my $usebs2b = $prefs->client($client)->get('bs2b');
my $flc = 'flc-flc-*-' . lc($client->macaddress);
if ($usebs2b) {
# AU is specifically designed to be written to a pipe (http://www.mega-nerd.com/libsndfile/FAQ.html#Q017)
my $cmdTable = '[sox] -q -t flac $FILE$ -t au - $START$ | [bs2bconvert] /dev/stdin /dev/stdout | [sox] -q -t au - -t flac -C 0 - ';
my $capabilities = { F => 'noArgs', T => 'START=trim %s' };
$Slim::Player::TranscodingHelper::commandTable{ $flc } = $cmdTable;
$Slim::Player::TranscodingHelper::capabilities{ $flc } = $capabilities;
} else {
my $cmdTable = '[flac] -dcs $START$ $END$ -- $FILE$ | [sox] -q -t wav - -t flac -C 0 -r 48000 - ';
my $capabilities = { F => 'noArgs', T => 'START=--skip=%t', U => 'END=--until=%v', D => 'RESAMPLE=-r %d' };
$Slim::Player::TranscodingHelper::commandTable{ $flc } = $cmdTable;
$Slim::Player::TranscodingHelper::capabilities{ $flc } = $capabilities;
}
}
sub initClient {
my $request = shift;
setupTranscoder($request->client());
}
1;