resindvd: Make the next/prev angle switching cycle at the ends

When the current angle is 1 and prev_angle is requested, loop to the
maximum angle and vice versa for next_angle
This commit is contained in:
Jan Schmidt 2009-05-05 11:34:26 +01:00
parent 9542d9e251
commit 874549b536

View file

@ -1172,6 +1172,7 @@ static RsnNavResult
rsn_dvdsrc_do_command (resinDvdSrc * src, GstNavigationCommand command) rsn_dvdsrc_do_command (resinDvdSrc * src, GstNavigationCommand command)
{ {
RsnNavResult result = RSN_NAV_RESULT_NONE; RsnNavResult result = RSN_NAV_RESULT_NONE;
gint new_angle = 0;
switch (command) { switch (command) {
case GST_NAVIGATION_COMMAND_DVD_MENU: case GST_NAVIGATION_COMMAND_DVD_MENU:
@ -1212,25 +1213,40 @@ rsn_dvdsrc_do_command (resinDvdSrc * src, GstNavigationCommand command)
case GST_NAVIGATION_COMMAND_PREV_ANGLE:{ case GST_NAVIGATION_COMMAND_PREV_ANGLE:{
gint32 cur, agls; gint32 cur, agls;
if (dvdnav_get_angle_info (src->dvdnav, &cur, &agls) == DVDNAV_STATUS_OK if (dvdnav_get_angle_info (src->dvdnav, &cur, &agls) == DVDNAV_STATUS_OK) {
&& cur > 0 if (cur > 0 &&
&& dvdnav_angle_change (src->dvdnav, cur - 1) == DVDNAV_STATUS_OK) dvdnav_angle_change (src->dvdnav, cur - 1) == DVDNAV_STATUS_OK) {
GST_INFO_OBJECT (src, "Switched to angle %d", cur - 1); new_angle = cur - 1;
/* Angle switches are seamless and involve no branching */ } else if (cur == 1 &&
dvdnav_angle_change (src->dvdnav, agls) == DVDNAV_STATUS_OK) {
new_angle = agls;
}
/* Angle switches are seamless and involve no branching */
}
break; break;
} }
case GST_NAVIGATION_COMMAND_NEXT_ANGLE:{ case GST_NAVIGATION_COMMAND_NEXT_ANGLE:{
gint32 cur, agls; gint32 cur, agls;
if (dvdnav_get_angle_info (src->dvdnav, &cur, &agls) == DVDNAV_STATUS_OK if (dvdnav_get_angle_info (src->dvdnav, &cur, &agls) == DVDNAV_STATUS_OK) {
&& dvdnav_angle_change (src->dvdnav, cur + 1) == DVDNAV_STATUS_OK) if (cur < agls
GST_INFO_OBJECT (src, "Switched to angle %d", cur + 1); && dvdnav_angle_change (src->dvdnav, cur + 1) == DVDNAV_STATUS_OK) {
/* Angle switches are seamless and involve no branching */ new_angle = cur + 1;
} else if (cur == agls
&& dvdnav_angle_change (src->dvdnav, 1) == DVDNAV_STATUS_OK) {
new_angle = 1;
}
/* Angle switches are seamless and involve no branching */
}
break; break;
} }
default: default:
break; break;
} }
if (new_angle) {
GST_INFO_OBJECT (src, "Switched to angle %d", new_angle);
}
return result; return result;
} }