avformat/libopenmpt: Query duration and metadata after selecting subsong
authorJörn Heusipp <osmanx@problemloesungsmaschine.de>
Sun, 17 Sep 2017 13:35:50 +0000 (15:35 +0200)
committerJosh de Kock <josh@itanimul.li>
Sun, 24 Sep 2017 14:54:38 +0000 (15:54 +0100)
Duration depends on the selected subsong and thus must be queried after
selecting the subsong. There is no compelling reason to query other
metadata earlier either.

Tested with libopenmpt version: 0.2.8760-beta27
Libopenmpt configure options: --without-ogg --without-vorbis
--without-vorbisfile --without-portaudio --without-portaudiocpp
--without-mpg123 --without-pulseaudio --without-sndfile --without-flac

Signed-off-by: Jörn Heusipp <osmanx@problemloesungsmaschine.de>
Signed-off-by: Josh de Kock <josh@itanimul.li>
libavformat/libopenmpt.c

index a7e3859..af6eb1a 100644 (file)
@@ -93,14 +93,7 @@ static int read_header_openmpt(AVFormatContext *s)
     if (!openmpt->module)
             return AVERROR_INVALIDDATA;
 
-    openmpt->channels   = av_get_channel_layout_nb_channels(openmpt->layout);
-    openmpt->duration   = openmpt_module_get_duration_seconds(openmpt->module);
-
-    add_meta(s, "artist",  openmpt_module_get_metadata(openmpt->module, "artist"));
-    add_meta(s, "title",   openmpt_module_get_metadata(openmpt->module, "title"));
-    add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
-    add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
-    add_meta(s, "date",    openmpt_module_get_metadata(openmpt->module, "date"));
+    openmpt->channels = av_get_channel_layout_nb_channels(openmpt->layout);
 
     if (openmpt->subsong >= openmpt_module_get_num_subsongs(openmpt->module)) {
         openmpt_module_destroy(openmpt->module);
@@ -120,6 +113,14 @@ static int read_header_openmpt(AVFormatContext *s)
         }
     }
 
+    openmpt->duration = openmpt_module_get_duration_seconds(openmpt->module);
+
+    add_meta(s, "artist",  openmpt_module_get_metadata(openmpt->module, "artist"));
+    add_meta(s, "title",   openmpt_module_get_metadata(openmpt->module, "title"));
+    add_meta(s, "encoder", openmpt_module_get_metadata(openmpt->module, "tracker"));
+    add_meta(s, "comment", openmpt_module_get_metadata(openmpt->module, "message"));
+    add_meta(s, "date",    openmpt_module_get_metadata(openmpt->module, "date"));
+
     st = avformat_new_stream(s, NULL);
     if (!st) {
         openmpt_module_destroy(openmpt->module);