qt: playlist: use item title if available
[vlc.git] / modules / audio_filter / resampler / src.c
index 7a460f0..51b955f 100644 (file)
@@ -52,7 +52,7 @@ static const char *const conv_type_texts[] = {
 
 static int Open (vlc_object_t *);
 static int OpenResampler (vlc_object_t *);
-static void Close (vlc_object_t *);
+static void Close (filter_t *);
 
 vlc_module_begin ()
     set_shortname (N_("SRC resampler"))
@@ -63,11 +63,11 @@ vlc_module_begin ()
                  SRC_CONV_TYPE_TEXT, SRC_CONV_TYPE_LONGTEXT, true)
         change_integer_list (conv_type_values, conv_type_texts)
     set_capability ("audio converter", 50)
-    set_callbacks (Open, Close)
+    set_callback (Open)
 
     add_submodule ()
     set_capability ("audio resampler", 50)
-    set_callbacks (OpenResampler, Close)
+    set_callback (OpenResampler)
 vlc_module_end ()
 
 static block_t *Resample (filter_t *, block_t *);
@@ -90,31 +90,31 @@ static int OpenResampler (vlc_object_t *obj)
     if (filter->fmt_in.audio.i_format != VLC_CODEC_FL32
      || filter->fmt_out.audio.i_format != VLC_CODEC_FL32
     /* No channels remapping */
-     || filter->fmt_in.audio.i_physical_channels
-                                  != filter->fmt_out.audio.i_physical_channels
-     || filter->fmt_in.audio.i_original_channels
-                                  != filter->fmt_out.audio.i_original_channels)
+     || filter->fmt_in.audio.i_channels != filter->fmt_out.audio.i_channels )
         return VLC_EGENERIC;
 
     int type = var_InheritInteger (obj, "src-converter-type");
-    int channels = aout_FormatNbChannels (&filter->fmt_in.audio);
     int err;
 
-    SRC_STATE *s = src_new (type, channels, &err);
+    SRC_STATE *s = src_new (type, filter->fmt_in.audio.i_channels, &err);
     if (s == NULL)
     {
         msg_Err (obj, "cannot initialize resampler: %s", src_strerror (err));
         return VLC_EGENERIC;
     }
 
-    filter->p_sys = (filter_sys_t *)s;
-    filter->pf_audio_filter = Resample;
+    static const struct vlc_filter_operations filter_ops =
+    {
+        .filter_audio = Resample, .close = Close,
+    };
+    filter->ops = &filter_ops;
+    filter->p_sys = s;
+
     return VLC_SUCCESS;
 }
 
-static void Close (vlc_object_t *obj)
+static void Close (filter_t *filter)
 {
-    filter_t *filter = (filter_t *)obj;
     SRC_STATE *s = (SRC_STATE *)filter->p_sys;
 
     src_delete (s);
@@ -166,8 +166,7 @@ static block_t *Resample (filter_t *filter, block_t *in)
     out->i_buffer = src.output_frames_gen * framesize;
     out->i_nb_samples = src.output_frames_gen;
     out->i_pts = in->i_pts;
-    out->i_length = src.output_frames_gen * CLOCK_FREQ
-                  / filter->fmt_out.audio.i_rate;
+    out->i_length = vlc_tick_from_samples(src.output_frames_gen, filter->fmt_out.audio.i_rate);
 error:
     block_Release (in);
     return out;