XineStream::XineStream(XineEngine &e, const string &mrl):
engine(e),
+ filename(mrl.substr(mrl.rfind('/')+1)),
state(STOPPED),
+ title(filename),
current_audio(0),
current_spu(OFF),
channels_changed(false)
engine.add_stream(*this);
}
+const string &XineStream::get_title() const
+{
+ return title.empty() ? filename : title;
+}
+
XineStream::~XineStream()
{
engine.remove_stream(*this);
xine_dispose(stream);
}
-void XineStream::select_audio_channel(int i)
-{
- if(i>=0 && static_cast<unsigned>(i)>=audio_channels.size())
- throw out_of_range("XineStream::set_audio_channel");
-
- if(i<0)
- i = OFF;
- xine_set_param(stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, (i==OFF ? -2 : i));
-}
-
-void XineStream::select_spu_channel(int i)
-{
- if(i>=0 && static_cast<unsigned>(i)>=spu_channels.size())
- throw out_of_range("XineStream::set_spu_channel");
-
- if(i<0)
- i = OFF;
- xine_set_param(stream, XINE_PARAM_SPU_CHANNEL, (i==OFF ? -2 : i));
-}
-
void XineStream::play()
{
if(state==STOPPED)
signal_state_changed.emit(state);
}
+void XineStream::select_audio_channel(int i)
+{
+ if(i>=0 && static_cast<unsigned>(i)>=audio_channels.size())
+ throw out_of_range("XineStream::set_audio_channel");
+
+ if(i<0)
+ i = OFF;
+ xine_set_param(stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, (i==OFF ? -2 : i));
+}
+
+void XineStream::select_spu_channel(int i)
+{
+ if(i>=0 && static_cast<unsigned>(i)>=spu_channels.size())
+ throw out_of_range("XineStream::set_spu_channel");
+
+ if(i<0)
+ i = OFF;
+ xine_set_param(stream, XINE_PARAM_SPU_CHANNEL, (i==OFF ? -2 : i));
+}
+
void XineStream::tick()
{
while(xine_event_t *event = xine_event_get(queue))
{
MutexLock lock(mutex);
title = (xt ? xt : string());
- signal_title_changed.emit(title);
+ signal_title_changed.emit(get_title());
}
int dur_msec, pos_msec;
audio_channels.resize(n_audio);
for(unsigned i=0; i<n_audio; ++i)
{
- xine_get_audio_lang(stream, i, langbuf);
- audio_channels[i].assign(langbuf);
+ if(xine_get_audio_lang(stream, i, langbuf))
+ audio_channels[i].assign(langbuf);
+ else
+ audio_channels[i].assign("unknown");
}
unsigned n_spu = xine_get_stream_info(stream, XINE_STREAM_INFO_MAX_SPU_CHANNEL);
spu_channels.resize(n_spu);
for(unsigned i=0; i<n_spu; ++i)
{
- xine_get_spu_lang(stream, i, langbuf);
- spu_channels[i].assign(langbuf);
+ if(xine_get_spu_lang(stream, i, langbuf))
+ spu_channels[i].assign(langbuf);
+ else
+ spu_channels[i].assign("unknown");
}
signal_channels_changed.emit();