winegstreamer: Retrieve and complete read requests through Unix library functions.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1babfe7d49
commit
86333a20c8
|
@ -226,6 +226,10 @@ struct unix_funcs
|
|||
void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
|
||||
void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
|
||||
|
||||
bool (CDECL *wg_parser_get_read_request)(struct wg_parser *parser,
|
||||
GstBuffer **buffer, uint64_t *offset, uint32_t *size);
|
||||
void (CDECL *wg_parser_complete_read_request)(struct wg_parser *parser, GstFlowReturn ret);
|
||||
|
||||
uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser);
|
||||
struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index);
|
||||
|
||||
|
|
|
@ -822,29 +822,22 @@ static GstFlowReturn read_buffer(struct parser *This, guint64 ofs, guint len, Gs
|
|||
static DWORD CALLBACK read_thread(void *arg)
|
||||
{
|
||||
struct parser *filter = arg;
|
||||
struct wg_parser *parser = filter->wg_parser;
|
||||
|
||||
TRACE("Starting read thread for filter %p.\n", filter);
|
||||
|
||||
pthread_mutex_lock(&parser->mutex);
|
||||
|
||||
while (filter->sink_connected)
|
||||
{
|
||||
while (parser->sink_connected && !parser->read_request.buffer)
|
||||
pthread_cond_wait(&parser->read_cond, &parser->mutex);
|
||||
GstBuffer *buffer;
|
||||
uint64_t offset;
|
||||
uint32_t size;
|
||||
|
||||
if (!parser->sink_connected)
|
||||
break;
|
||||
if (!unix_funcs->wg_parser_get_read_request(filter->wg_parser, &buffer, &offset, &size))
|
||||
continue;
|
||||
|
||||
parser->read_request.done = true;
|
||||
parser->read_request.ret = read_buffer(filter, parser->read_request.offset,
|
||||
parser->read_request.size, parser->read_request.buffer);
|
||||
parser->read_request.buffer = NULL;
|
||||
pthread_cond_signal(&parser->read_done_cond);
|
||||
unix_funcs->wg_parser_complete_read_request(filter->wg_parser,
|
||||
read_buffer(filter, offset, size, buffer));
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&parser->mutex);
|
||||
|
||||
TRACE("Streaming stopped; exiting.\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -349,6 +349,38 @@ static void CDECL wg_parser_end_flush(struct wg_parser *parser)
|
|||
pthread_mutex_unlock(&parser->mutex);
|
||||
}
|
||||
|
||||
static bool CDECL wg_parser_get_read_request(struct wg_parser *parser,
|
||||
GstBuffer **buffer, uint64_t *offset, uint32_t *size)
|
||||
{
|
||||
pthread_mutex_lock(&parser->mutex);
|
||||
|
||||
while (parser->sink_connected && !parser->read_request.buffer)
|
||||
pthread_cond_wait(&parser->read_cond, &parser->mutex);
|
||||
|
||||
if (!parser->sink_connected)
|
||||
{
|
||||
pthread_mutex_unlock(&parser->mutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
*buffer = parser->read_request.buffer;
|
||||
*offset = parser->read_request.offset;
|
||||
*size = parser->read_request.size;
|
||||
|
||||
pthread_mutex_unlock(&parser->mutex);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void CDECL wg_parser_complete_read_request(struct wg_parser *parser, GstFlowReturn ret)
|
||||
{
|
||||
pthread_mutex_lock(&parser->mutex);
|
||||
parser->read_request.done = true;
|
||||
parser->read_request.ret = ret;
|
||||
parser->read_request.buffer = NULL;
|
||||
pthread_mutex_unlock(&parser->mutex);
|
||||
pthread_cond_signal(&parser->read_done_cond);
|
||||
}
|
||||
|
||||
static void CDECL wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format)
|
||||
{
|
||||
*format = stream->preferred_format;
|
||||
|
@ -1663,6 +1695,9 @@ static const struct unix_funcs funcs =
|
|||
wg_parser_begin_flush,
|
||||
wg_parser_end_flush,
|
||||
|
||||
wg_parser_get_read_request,
|
||||
wg_parser_complete_read_request,
|
||||
|
||||
wg_parser_get_stream_count,
|
||||
wg_parser_get_stream,
|
||||
|
||||
|
|
Loading…
Reference in New Issue