winegstreamer: Also wait for EOS events when retrieving duration.

The mpegaudioparse element will not send a duration-changed message if no
Xing or VBRI headers are present.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2020-06-13 10:34:22 -05:00 committed by Alexandre Julliard
parent 5444ce2f0d
commit bd28efb4c7
4 changed files with 15 additions and 8 deletions

View File

@ -523,13 +523,13 @@ static void test_media_types(void)
{ {
MPEG1WAVEFORMAT expect_wfx = MPEG1WAVEFORMAT expect_wfx =
{ {
{WAVE_FORMAT_MPEG, 1, 48000, 8000, 192, 0, sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX)}, {WAVE_FORMAT_MPEG, 1, 48000, 4000, 96, 0, sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX)},
ACM_MPEG_LAYER3, 64000, ACM_MPEG_SINGLECHANNEL, 0, 1, ACM_MPEG_PROTECTIONBIT | ACM_MPEG_ID_MPEG1, 0, 0 ACM_MPEG_LAYER3, 32000, ACM_MPEG_SINGLECHANNEL, 4096, 1, ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT | ACM_MPEG_ID_MPEG1, 0, 0
}; };
static const MPEGLAYER3WAVEFORMAT expect_mp3_wfx = static const MPEGLAYER3WAVEFORMAT expect_mp3_wfx =
{ {
{WAVE_FORMAT_MPEGLAYER3, 1, 48000, 8000, 1, 0, sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX)}, {WAVE_FORMAT_MPEGLAYER3, 1, 48000, 4000, 1, 0, sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX)},
MPEGLAYER3_ID_MPEG, 0, 192, 1, 0 MPEGLAYER3_ID_MPEG, 0, 96, 1, 0
}; };
const WCHAR *filename = load_resource(L"test.mp3"); const WCHAR *filename = load_resource(L"test.mp3");

View File

@ -28,7 +28,7 @@ test.avi RCDATA "test.avi"
/* @makedep: test.mpg */ /* @makedep: test.mpg */
test.mpg RCDATA "test.mpg" test.mpg RCDATA "test.mpg"
/* ffmpeg -f lavfi -i "sine=frequency=500" -t 0.5 -ar 48000 -b:a 32k -f mp3 -acodec mp3 test.mp3 */ /* ffmpeg -f lavfi -i "sine=frequency=500" -t 0.5 -ar 48000 -b:a 32k -f mp3 -acodec mp3 -write_xing 0 test.mp3 */
/* @makedep: test.mp3 */ /* @makedep: test.mp3 */
test.mp3 RCDATA "test.mp3" test.mp3 RCDATA "test.mp3"

Binary file not shown.

View File

@ -79,7 +79,7 @@ struct gstdemux_source
GstPad *their_src, *post_sink, *post_src, *my_sink; GstPad *their_src, *post_sink, *post_src, *my_sink;
GstElement *flip; GstElement *flip;
AM_MEDIA_TYPE mt; AM_MEDIA_TYPE mt;
HANDLE caps_event; HANDLE caps_event, eos_event;
GstSegment *segment; GstSegment *segment;
SourceSeeking seek; SourceSeeking seek;
}; };
@ -699,6 +699,8 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event)
case GST_EVENT_EOS: case GST_EVENT_EOS:
if (pin->pin.pin.peer) if (pin->pin.pin.peer)
IPin_EndOfStream(pin->pin.pin.peer); IPin_EndOfStream(pin->pin.pin.peer);
else
SetEvent(pin->eos_event);
return TRUE; return TRUE;
case GST_EVENT_FLUSH_START: case GST_EVENT_FLUSH_START:
if (impl_from_strmbase_filter(pin->pin.pin.filter)->ignore_flush) { if (impl_from_strmbase_filter(pin->pin.pin.filter)->ignore_flush) {
@ -2129,6 +2131,7 @@ static void free_source_pin(struct gstdemux_source *pin)
} }
gst_object_unref(pin->my_sink); gst_object_unref(pin->my_sink);
CloseHandle(pin->caps_event); CloseHandle(pin->caps_event);
CloseHandle(pin->eos_event);
FreeMediaType(&pin->mt); FreeMediaType(&pin->mt);
gst_segment_free(pin->segment); gst_segment_free(pin->segment);
@ -2161,6 +2164,7 @@ static struct gstdemux_source *create_pin(struct gstdemux *filter, const WCHAR *
strmbase_source_init(&pin->pin, &filter->filter, name, &source_ops); strmbase_source_init(&pin->pin, &filter->filter, name, &source_ops);
pin->caps_event = CreateEventW(NULL, FALSE, FALSE, NULL); pin->caps_event = CreateEventW(NULL, FALSE, FALSE, NULL);
pin->eos_event = CreateEventW(NULL, FALSE, FALSE, NULL);
pin->segment = gst_segment_new(); pin->segment = gst_segment_new();
gst_segment_init(pin->segment, GST_FORMAT_TIME); gst_segment_init(pin->segment, GST_FORMAT_TIME);
pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl; pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl;
@ -2561,7 +2565,8 @@ static BOOL mpeg_splitter_init_gst(struct gstdemux *filter)
static const WCHAR source_name[] = {'A','u','d','i','o',0}; static const WCHAR source_name[] = {'A','u','d','i','o',0};
struct gstdemux_source *pin; struct gstdemux_source *pin;
GstElement *element; GstElement *element;
HANDLE events[2]; HANDLE events[3];
DWORD res;
int ret; int ret;
if (!(element = gst_element_factory_make("mpegaudioparse", NULL))) if (!(element = gst_element_factory_make("mpegaudioparse", NULL)))
@ -2600,7 +2605,9 @@ static BOOL mpeg_splitter_init_gst(struct gstdemux *filter)
events[0] = filter->duration_event; events[0] = filter->duration_event;
events[1] = filter->error_event; events[1] = filter->error_event;
if (WaitForMultipleObjects(2, events, FALSE, INFINITE)) events[2] = pin->eos_event;
res = WaitForMultipleObjects(3, events, FALSE, INFINITE);
if (res == 1)
return FALSE; return FALSE;
pin->seek.llDuration = pin->seek.llStop = query_duration(pin->their_src); pin->seek.llDuration = pin->seek.llStop = query_duration(pin->their_src);