Commit eed8bfbf authored by hpi1's avatar hpi1

Update selected audio and subtitle stream PSRs when not using menus.

Selection is based on language setting PSRs and clip STN.
parent f06398fe
......@@ -208,6 +208,74 @@ static int _queue_event(BLURAY *bd, BD_EVENT ev)
return 0;
}
/*
* PSR utils
*/
static void _update_stream_psr_by_lang(BD_REGISTERS *regs,
uint32_t psr_lang, uint32_t psr_stream,
uint32_t enable_flag, uint32_t undefined_val,
MPLS_STREAM *streams, unsigned num_streams)
{
uint32_t psr_val;
int stream_idx = -1;
unsigned ii;
/* get preferred language */
psr_val = bd_psr_read(regs, psr_lang);
if (psr_val == 0xffffff) {
/* language setting not initialized */
return;
}
/* find stream */
for (ii = 0; ii < num_streams; ii++) {
if (psr_val == str_to_uint32((const char *)streams[ii].lang, 3)) {
stream_idx = ii;
break;
}
}
if (stream_idx < 0) {
/* requested language not found */
stream_idx = undefined_val - 1;
enable_flag = 0;
}
/* update PSR */
BD_DEBUG(DBG_BLURAY, "Selected stream %d (language %s)\n", ii, streams[ii].lang);
bd_psr_lock(regs);
psr_val = bd_psr_read(regs, psr_stream) & 0xffff0000;
psr_val |= (stream_idx + 1) | enable_flag;
bd_psr_write(regs, psr_stream, psr_val);
bd_psr_unlock(regs);
}
static void _update_clip_psrs(BLURAY *bd, NAV_CLIP *clip)
{
bd_psr_write(bd->regs, PSR_PLAYITEM, clip->ref);
bd_psr_write(bd->regs, PSR_TIME, clip->in_time);
/* Update selected audio and subtitle stream PSRs when not using menus.
* Selection is based on language setting PSRs and clip STN.
*/
if (bd->title_type == title_undef) {
MPLS_STN *stn = &clip->title->pl->play_item[clip->ref].stn;
_update_stream_psr_by_lang(bd->regs,
PSR_AUDIO_LANG, PSR_PRIMARY_AUDIO_ID, 0, 0xff,
stn->audio, stn->num_audio);
_update_stream_psr_by_lang(bd->regs,
PSR_PG_AND_SUB_LANG, PSR_PG_STREAM, 0x80000000, 0xfff,
stn->pg, stn->num_pg);
}
}
/*
* clip access (BD_STREAM)
*/
......@@ -251,8 +319,7 @@ static int _open_m2ts(BLURAY *bd, BD_STREAM *st)
}
if (st == &bd->st0) {
bd_psr_write(bd->regs, PSR_PLAYITEM, st->clip->ref);
bd_psr_write(bd->regs, PSR_TIME, st->clip->in_time);
_update_clip_psrs(bd, st->clip);
}
return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment