Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looping files #150

Merged
merged 2 commits into from
Mar 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Using OMXPlayer
-g / --genlog generate log file
-l / --pos n start position (hh:mm:ss)
-b / --blank set background to black
--loop loop file. Ignored if file is not seekable, start position applied if given
--no-boost-on-downmix don't boost volume when downmixing
--vol n Set initial volume in millibels (default 0)
--no-osd do not display status information on screen
Expand Down
18 changes: 18 additions & 0 deletions omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ bool m_has_subtitle = false;
float m_display_aspect = 0.0f;
bool m_boost_on_downmix = true;
bool m_gen_log = false;
bool m_loop = false;

enum{ERROR=-1,SUCCESS,ONEBYTE};

Expand Down Expand Up @@ -164,6 +165,7 @@ void print_usage()
printf(" -g / --genlog generate log file\n");
printf(" -l / --pos n start position (hh:mm:ss)\n");
printf(" -b / --blank set background to black\n");
printf(" --loop loop file. Ignored if file is not seekable, start position applied if given\n");
printf(" --no-boost-on-downmix don't boost volume when downmixing\n");
printf(" --vol n Set initial volume in millibels (default 0)\n");
printf(" --amp n Set initial amplification in millibels (default 0)\n");
Expand Down Expand Up @@ -563,6 +565,7 @@ int main(int argc, char *argv[])
bool m_new_win_pos = false;
std::string m_filename;
double m_incr = 0;
double m_loop_from = 0;
CRBP g_RBP;
COMXCore g_OMX;
bool m_stats = false;
Expand Down Expand Up @@ -610,6 +613,7 @@ int main(int argc, char *argv[])
const int live_opt = 0x205;
const int layout_opt = 0x206;
const int dbus_name_opt = 0x209;
const int loop_opt = 0x20a;

struct option longopts[] = {
{ "info", no_argument, NULL, 'i' },
Expand Down Expand Up @@ -655,6 +659,7 @@ int main(int argc, char *argv[])
{ "live", no_argument, NULL, live_opt },
{ "layout", required_argument, NULL, layout_opt },
{ "dbus_name", required_argument, NULL, dbus_name_opt },
{ "loop", no_argument, NULL, loop_opt },
{ 0, 0, 0, 0 }
};

Expand Down Expand Up @@ -747,6 +752,8 @@ int main(int argc, char *argv[])
{
m_incr = atof(optarg);
}
if(m_loop)
m_loop_from = m_incr;
}
break;
case no_osd_opt:
Expand Down Expand Up @@ -839,6 +846,11 @@ int main(int argc, char *argv[])
case dbus_name_opt:
m_dbus_name = optarg;
break;
case loop_opt:
if(m_incr != 0)
m_loop_from = m_incr;
m_loop = true;
break;
case 'b':
m_blank_background = true;
break;
Expand Down Expand Up @@ -963,6 +975,7 @@ int main(int argc, char *argv[])
m_has_audio = m_omx_reader.AudioStreamCount();
m_has_subtitle = m_has_external_subtitles ||
m_omx_reader.SubtitleStreamCount();
m_loop = m_loop && m_omx_reader.CanSeek();

if (m_audio_extension)
{
Expand Down Expand Up @@ -1629,6 +1642,11 @@ int main(int argc, char *argv[])
OMXClock::OMXSleep(10);
continue;
}
if (m_loop)
{
m_incr = m_loop_from - (m_av_clock->OMXMediaTime() ? m_av_clock->OMXMediaTime() / DVD_TIME_BASE : last_seek_pos);
continue;
}
if (!m_send_eos && m_has_video)
m_player_video.SubmitEOS();
if (!m_send_eos && m_has_audio)
Expand Down