The new SVDRP command 'AUDI' can be used to list the currently available audio tracks and select one of them

This commit is contained in:
Klaus Schmidinger 2024-08-30 09:55:15 +02:00
parent a33adf365d
commit 71b0140003
4 changed files with 59 additions and 6 deletions

View File

@ -9952,7 +9952,7 @@ Video Disk Recorder Revision History
- Added the lines from 'Fixed a timeout in cDvbDevice while tuning after the frontend
has been reopened' to cDvbTuner::ProvidesFrontend() (suggested by Markus Ehrnsperger).
2024-07-16:
2024-08-30:
- Removed deprecated function cDevice::SetCurrentChannel(const cChannel *Channel).
- Removed deprecated function cSkinDisplayMenu::SetItemEvent(const cEvent *Event, int Index,
@ -9974,3 +9974,5 @@ Video Disk Recorder Revision History
instead.
- Changed the error message when trying to attach a player to a primary device without
an MPEG decoder.
- The new SVDRP command 'AUDI' can be used to list the currently available audio tracks
and select one of them.

4
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 5.14 2024/06/25 19:00:06 kls Exp $
* $Id: menu.c 5.15 2024/08/30 09:55:15 kls Exp $
*/
#include "menu.h"
@ -4677,7 +4677,7 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
// --- SetTrackDescriptions --------------------------------------------------
static void SetTrackDescriptions(int LiveChannel)
void SetTrackDescriptions(int LiveChannel)
{
cDevice::PrimaryDevice()->ClrAvailableTracks(true);
const cComponents *Components = NULL;

4
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.h 5.2 2024/06/25 19:00:06 kls Exp $
* $Id: menu.h 5.3 2024/08/30 09:55:15 kls Exp $
*/
#ifndef __MENU_H
@ -334,4 +334,6 @@ public:
static void ClearLastReplayed(const char *FileName);
};
void SetTrackDescriptions(int LiveChannel);
#endif //__MENU_H

53
svdrp.c
View File

@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
* $Id: svdrp.c 5.8 2024/06/13 09:31:11 kls Exp $
* $Id: svdrp.c 5.9 2024/08/30 09:55:15 kls Exp $
*/
#include "svdrp.h"
@ -823,6 +823,14 @@ bool cPUTEhandler::Process(const char *s)
// adjust the help for CLRE accordingly if changing this!
const char *HelpPages[] = {
"AUDI [ <number> ]\n"
" Lists the currently available audio tracks in the format 'number language description'.\n"
" The number indicates the track type (1..32 = MP2, 33..48 = Dolby).\n"
" The currently selected track has its description prefixed with '*'.\n"
" If a number is given (which must be one of the track numbers listed)\n"
" audio is switched to that track.\n"
" Note that the list may not be fully available or current immediately after\n"
" switching the channel or starting a replay.",
"CHAN [ + | - | <number> | <name> | <id> ]\n"
" Switch channel up, down or to the given channel number, name or id.\n"
" Without option (or after successfully switching to the channel)\n"
@ -1071,6 +1079,7 @@ private:
bool Send(const char *s);
void Reply(int Code, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
void PrintHelpTopics(const char **hp);
void CmdAUDI(const char *Option);
void CmdCHAN(const char *Option);
void CmdCLRE(const char *Option);
void CmdCONN(const char *Option);
@ -1228,6 +1237,45 @@ void cSVDRPServer::PrintHelpTopics(const char **hp)
}
}
void cSVDRPServer::CmdAUDI(const char *Option)
{
if (*Option) {
if (isnumber(Option)) {
int o = strtol(Option, NULL, 10);
if (o >= ttAudioFirst && o <= ttDolbyLast) {
const tTrackId *TrackId = cDevice::PrimaryDevice()->GetTrack(eTrackType(o));
if (TrackId && TrackId->id) {
cDevice::PrimaryDevice()->SetCurrentAudioTrack(eTrackType(o));
Reply(250, cString::sprintf("%d %s %s", eTrackType(o), *TrackId->language ? TrackId->language : "---", *TrackId->description ? TrackId->description : "-"));
}
else
Reply(501, "Audio track \"%s\" not available", Option);
}
else
Reply(501, "Invalid audio track \"%s\"", Option);
}
else
Reply(501, "Error in audio track \"%s\"", Option);
}
else {
SetTrackDescriptions(!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring() ? cDevice::CurrentChannel() : 0);
eTrackType CurrentAudioTrack = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
cString s;
for (int i = ttAudioFirst; i <= ttDolbyLast; i++) {
const tTrackId *TrackId = cDevice::PrimaryDevice()->GetTrack(eTrackType(i));
if (TrackId && TrackId->id) {
if (*s)
Reply(-250, s);
s = cString::sprintf("%d %s %s%s", eTrackType(i), *TrackId->language ? TrackId->language : "---", i == CurrentAudioTrack ? "*" : "", *TrackId->description ? TrackId->description : "-");
}
}
if (*s)
Reply(250, s);
else
Reply(550, "No audio tracks available");
}
}
void cSVDRPServer::CmdCHAN(const char *Option)
{
LOCK_CHANNELS_READ;
@ -2571,7 +2619,8 @@ void cSVDRPServer::Execute(char *Cmd)
if (*s)
*s++ = 0;
s = skipspace(s);
if (CMD("CHAN")) CmdCHAN(s);
if (CMD("AUDI")) CmdAUDI(s);
else if (CMD("CHAN")) CmdCHAN(s);
else if (CMD("CLRE")) CmdCLRE(s);
else if (CMD("CONN")) CmdCONN(s);
else if (CMD("DELC")) CmdDELC(s);