mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 14:36:41 +00:00
festival: enhance some error case handling
This commit is contained in:
parent
ae02c7820b
commit
c004a1e462
1 changed files with 25 additions and 4 deletions
|
@ -297,22 +297,29 @@ gst_festival_chain (GstPad * pad, GstBuffer * buf)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstFestival *festival;
|
GstFestival *festival;
|
||||||
guint8 *p, *ep;
|
guint8 *p, *ep;
|
||||||
|
gint f;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
|
||||||
festival = GST_FESTIVAL (GST_PAD_PARENT (pad));
|
festival = GST_FESTIVAL (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
GST_LOG_OBJECT (festival, "Got text buffer, %u bytes", GST_BUFFER_SIZE (buf));
|
GST_LOG_OBJECT (festival, "Got text buffer, %u bytes", GST_BUFFER_SIZE (buf));
|
||||||
|
|
||||||
fd = fdopen (dup (festival->info->server_fd), "wb");
|
f = dup (festival->info->server_fd);
|
||||||
|
if (f < 0)
|
||||||
|
goto fail_open;
|
||||||
|
fd = fdopen (f, "wb");
|
||||||
|
if (fd == NULL) {
|
||||||
|
close (f);
|
||||||
|
goto fail_open;
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy text over to server, escaping any quotes */
|
/* Copy text over to server, escaping any quotes */
|
||||||
fprintf (fd, "(Parameter.set 'Audio_Required_Rate 16000)\n");
|
fprintf (fd, "(Parameter.set 'Audio_Required_Rate 16000)\n");
|
||||||
fflush (fd);
|
fflush (fd);
|
||||||
GST_DEBUG_OBJECT (festival, "issued Parameter.set command");
|
GST_DEBUG_OBJECT (festival, "issued Parameter.set command");
|
||||||
if (read_response (festival) == FALSE) {
|
if (read_response (festival) == FALSE) {
|
||||||
ret = GST_FLOW_ERROR;
|
|
||||||
fclose (fd);
|
fclose (fd);
|
||||||
goto out;
|
goto fail_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (fd, "(tts_textall \"");
|
fprintf (fd, "(tts_textall \"");
|
||||||
|
@ -332,11 +339,25 @@ gst_festival_chain (GstPad * pad, GstBuffer * buf)
|
||||||
|
|
||||||
/* Read back info from server */
|
/* Read back info from server */
|
||||||
if (read_response (festival) == FALSE)
|
if (read_response (festival) == FALSE)
|
||||||
ret = GST_FLOW_ERROR;
|
goto fail_read;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
fail_open:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (festival, RESOURCE, OPEN_WRITE, (NULL), (NULL));
|
||||||
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
fail_read:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (festival, RESOURCE, READ, (NULL), (NULL));
|
||||||
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FT_Info *
|
static FT_Info *
|
||||||
|
|
Loading…
Reference in a new issue