Skip to content

Commit 123d00f

Browse files
committed
Fix: PT1/PT2/PT3 の Chardev 版ドライバでは TSID 選局を行わない
1 parent 920afad commit 123d00f

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

isdb_scanner/formatter.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,16 @@ def format(self) -> str:
442442
str: フォーマットされた文字列
443443
"""
444444

445-
def get_tuner_command(device_path: Path) -> str:
445+
def get_tuner_command(tuner: ISDBTuner) -> str:
446446
if self._recpt1_compatible is True:
447-
return f'recpt1 --device {device_path} <channel> - -'
447+
return f'recpt1 --device {tuner.device_path} <channel> - -'
448448
else:
449449
# <satellite> は mirakc における {{{extra_args}}} の代わりとして使っている
450-
# TSID 選局に対応しているチューナーでは、BS のみ <satellite> が --tsid (BS チャンネルの TSID) に置換される
451-
return f'recisdb tune --device {device_path} --channel <channel> <satellite> -'
450+
# TSID 選局に対応しているチューナーでは、BS のみ <satellite> を --tsid (BS チャンネルの TSID) に置換する
451+
if tuner.isTSIDSelectionSupported() is True:
452+
return f'recisdb tune --device {tuner.device_path} --channel <channel> <satellite> -'
453+
else:
454+
return f'recisdb tune --device {tuner.device_path} --channel <channel> -'
452455

453456
# Mirakurun のチューナー設定ファイル用のデータ構造に変換
454457
mirakurun_tuners: list[MirakurunTuner] = []
@@ -459,7 +462,7 @@ def get_tuner_command(device_path: Path) -> str:
459462
tuner: MirakurunTuner = {
460463
'name': isdbt_tuner.name,
461464
'types': ['GR'],
462-
'command': get_tuner_command(isdbt_tuner.device_path),
465+
'command': get_tuner_command(isdbt_tuner),
463466
}
464467
if self._recpt1_compatible is True:
465468
# recpt1 にも B25 デコード機能はあるが、安定性に難があるらしいので arib-b25-stream-test を使用する
@@ -474,7 +477,7 @@ def get_tuner_command(device_path: Path) -> str:
474477
tuner: MirakurunTuner = {
475478
'name': isdbs_tuner.name,
476479
'types': ['BS', 'CS'],
477-
'command': get_tuner_command(isdbs_tuner.device_path),
480+
'command': get_tuner_command(isdbs_tuner),
478481
}
479482
if self._recpt1_compatible is True:
480483
# recpt1 にも B25 デコード機能はあるが、安定性に難があるらしいので arib-b25-stream-test を使用する
@@ -489,7 +492,7 @@ def get_tuner_command(device_path: Path) -> str:
489492
tuner: MirakurunTuner = {
490493
'name': multi_tuner.name,
491494
'types': ['GR', 'BS', 'CS'],
492-
'command': get_tuner_command(multi_tuner.device_path),
495+
'command': get_tuner_command(multi_tuner),
493496
}
494497
if self._recpt1_compatible is True:
495498
# recpt1 にも B25 デコード機能はあるが、安定性に難があるらしいので arib-b25-stream-test を使用する
@@ -655,12 +658,15 @@ def format(self) -> str:
655658
}
656659
cast(list[MirakcChannel], mirakc_config['channels']).append(channel)
657660

658-
def get_tuner_command(device_path: Path) -> str:
661+
def get_tuner_command(tuner: ISDBTuner) -> str:
659662
if self._recpt1_compatible is True:
660-
return f'recpt1 --device {device_path} ' + '{{{channel}}} - -'
663+
return f'recpt1 --device {tuner.device_path} ' + '{{{channel}}} - -'
661664
else:
662-
# TSID 選局に対応しているチューナーでは、BS のみ <satellite> が --tsid (BS チャンネルの TSID) に置換される
663-
return f'recisdb tune --device {device_path} --channel ' + '{{{channel}}} {{{extra_args}}} -'
665+
# TSID 選局に対応しているチューナーでは、BS のみ <satellite> を --tsid (BS チャンネルの TSID) に置換する
666+
if tuner.isTSIDSelectionSupported() is True:
667+
return f'recisdb tune --device {tuner.device_path} --channel ' + '{{{channel}}} {{{extra_args}}} -'
668+
else:
669+
return f'recisdb tune --device {tuner.device_path} --channel ' + '{{{channel}}} -'
664670

665671
# mirakc のチューナー設定ファイル用のデータ構造に変換
666672
for isdbt_tuner in self._isdbt_tuners:
@@ -670,7 +676,7 @@ def get_tuner_command(device_path: Path) -> str:
670676
tuner: MirakcTuner = {
671677
'name': isdbt_tuner.name,
672678
'types': ['GR'],
673-
'command': get_tuner_command(isdbt_tuner.device_path),
679+
'command': get_tuner_command(isdbt_tuner),
674680
'disabled': False,
675681
}
676682
cast(list[MirakcTuner], mirakc_config['tuners']).append(tuner)
@@ -681,7 +687,7 @@ def get_tuner_command(device_path: Path) -> str:
681687
tuner: MirakcTuner = {
682688
'name': isdbs_tuner.name,
683689
'types': ['BS', 'CS'],
684-
'command': get_tuner_command(isdbs_tuner.device_path),
690+
'command': get_tuner_command(isdbs_tuner),
685691
'disabled': False,
686692
}
687693
cast(list[MirakcTuner], mirakc_config['tuners']).append(tuner)
@@ -692,7 +698,7 @@ def get_tuner_command(device_path: Path) -> str:
692698
tuner: MirakcTuner = {
693699
'name': multi_tuner.name,
694700
'types': ['GR', 'BS', 'CS'],
695-
'command': get_tuner_command(multi_tuner.device_path),
701+
'command': get_tuner_command(multi_tuner),
696702
'disabled': False,
697703
}
698704
cast(list[MirakcTuner], mirakc_config['tuners']).append(tuner)

isdb_scanner/tuner.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,36 @@ def GetPT1PT3PX4VideoDeviceInfo() -> tuple[Literal['ISDB-T', 'ISDB-S'], int]:
244244
## 現状すべて網羅しているつもりだが、念のため
245245
raise TunerNotSupportedError(f'Unsupported tuner device (Chardev): {self._device_path}')
246246

247+
def isTSIDSelectionSupported(self) -> bool:
248+
"""
249+
BS チャンネルの TSID 選局に対応しているチューナーかどうかを返す
250+
251+
V4L-DVB デバイスは全て TSID 選局に対応している
252+
Chardev デバイスでは、Earthsoft PT1/PT2/PT3 ドライバは TSID 選局に対応していないが、それ以外は対応している
253+
254+
Returns:
255+
bool: BS チャンネルの TSID 選局に対応しているチューナーかどうか
256+
"""
257+
258+
# V4L-DVB デバイスは全て TSID 選局に対応している
259+
if self._device_type == 'V4L-DVB':
260+
return True
261+
262+
# Chardev デバイスでは、特定のドライバを除いてサポートされる
263+
elif self._device_type == 'Chardev':
264+
# Earthsoft PT1 / PT2 ドライバは TSID 選局に対応していない
265+
if str(self._device_path).startswith('/dev/pt1video'):
266+
return False
267+
# Earthsoft PT3 ドライバは TSID 選局に対応していない
268+
if str(self._device_path).startswith('/dev/pt3video'):
269+
return False
270+
# それ以外の Chardev デバイスは TSID 選局に対応している
271+
## 正確には tsukumijima/px4_drv でしか対応していない (本家 nns779/px4_drv は対応していない) が、
272+
## 本家は長らく更新が止まっており最新のカーネルにも対応していないので、大半が移行済みのはず…
273+
return True
274+
275+
assert False # 通常到達しない
276+
247277
def isBusy(self) -> bool:
248278
"""
249279
チューナーデバイスが使用中かどうかを取得する

0 commit comments

Comments
 (0)