1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-02-15 04:42:06 +00:00

gstencoder: exit if pipeline encounter error, EOS or enter NULL state

Change-Id: Id9934d144bf023b301d92b24cc1cafcf2bac3b8e
This commit is contained in:
Derek Dai 2017-04-23 22:18:16 +08:00
parent c44f2dbcec
commit cc3f773a89

View file

@ -293,6 +293,8 @@ internal class GstEncoder : DispdEncoder, GLib.Object
} }
pipeline.set_state(Gst.State.NULL); pipeline.set_state(Gst.State.NULL);
state = DispdEncoderState.NULL;
defered_terminate();
} }
public async void prepare() throws Error public async void prepare() throws Error
@ -312,6 +314,14 @@ internal class GstEncoder : DispdEncoder, GLib.Object
Posix.fsync(3); Posix.fsync(3);
} }
private void defered_terminate()
{
Timeout.add(100, () => {
loop.quit();
return false;
});
}
private void check_configs() throws DispdEncoderError private void check_configs() throws DispdEncoderError
{ {
if(null == configs || null == pipeline) { if(null == configs || null == pipeline) {
@ -331,10 +341,12 @@ internal class GstEncoder : DispdEncoder, GLib.Object
switch(m.type) { switch(m.type) {
case Gst.MessageType.EOS: case Gst.MessageType.EOS:
error("unexpected EOS"); error("unexpected EOS");
defered_terminate();
break; break;
case Gst.MessageType.ERROR: case Gst.MessageType.ERROR:
m.parse_error(out e, out d); m.parse_error(out e, out d);
error("unexpected error: %s\n%s".printf(e.message, d)); error("unexpected error: %s\n%s".printf(e.message, d));
defered_terminate();
break; break;
case Gst.MessageType.STATE_CHANGED: case Gst.MessageType.STATE_CHANGED:
Gst.State oldstate; Gst.State oldstate;
@ -354,13 +366,6 @@ internal class GstEncoder : DispdEncoder, GLib.Object
state = DispdEncoderState.PAUSED; state = DispdEncoderState.PAUSED;
} }
break; break;
case Gst.State.NULL:
state = DispdEncoderState.NULL;
Timeout.add(100, () => {
loop.quit();
return false;
});
break;
} }
break; break;
default: default: