summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/inter/gstinteraudiosrc.c22
-rw-r--r--gst/inter/gstinteraudiosrc.h3
2 files changed, 20 insertions, 5 deletions
diff --git a/gst/inter/gstinteraudiosrc.c b/gst/inter/gstinteraudiosrc.c
index d1d2ea6fd..ee8786e98 100644
--- a/gst/inter/gstinteraudiosrc.c
+++ b/gst/inter/gstinteraudiosrc.c
@@ -187,6 +187,7 @@ gst_inter_audio_src_set_caps (GstBaseSrc * src, GstCaps * caps)
{
GstInterAudioSrc *interaudiosrc = GST_INTER_AUDIO_SRC (src);
const GstStructure *structure;
+ GstAudioInfo info;
gboolean ret;
int sample_rate;
@@ -201,6 +202,10 @@ gst_inter_audio_src_set_caps (GstBaseSrc * src, GstCaps * caps)
ret = gst_pad_set_caps (src->srcpad, caps);
}
+ if (gst_audio_info_from_caps (&info, caps)) {
+ interaudiosrc->finfo = info.finfo;
+ }
+
return ret;
}
@@ -226,6 +231,7 @@ gst_inter_audio_src_stop (GstBaseSrc * src)
gst_inter_surface_unref (interaudiosrc->surface);
interaudiosrc->surface = NULL;
+ interaudiosrc->finfo = NULL;
return TRUE;
}
@@ -282,17 +288,23 @@ gst_inter_audio_src_create (GstBaseSrc * src, guint64 offset, guint size,
if (n > 0) {
buffer = gst_adapter_take_buffer (interaudiosrc->surface->audio_adapter,
n * 4);
+ } else {
+ buffer = gst_buffer_new ();
}
g_mutex_unlock (&interaudiosrc->surface->mutex);
if (n < SIZE) {
- GstBuffer *newbuf = gst_buffer_new_and_alloc ((SIZE - n) * 4);
+ GstMapInfo map;
+ GstMemory *mem;
GST_WARNING ("creating %d samples of silence", SIZE - n);
-
- if (buffer)
- newbuf = gst_buffer_append (newbuf, buffer);
- buffer = newbuf;
+ mem = gst_allocator_alloc (NULL, (SIZE - n) * 4, NULL);
+ if (gst_memory_map (mem, &map, GST_MAP_WRITE)) {
+ gst_audio_format_fill_silence (interaudiosrc->finfo, map.data, map.size);
+ gst_memory_unmap (mem, &map);
+ }
+ buffer = gst_buffer_make_writable (buffer);
+ gst_buffer_prepend_memory (buffer, mem);
}
n = SIZE;
diff --git a/gst/inter/gstinteraudiosrc.h b/gst/inter/gstinteraudiosrc.h
index a86d5c025..318bb39de 100644
--- a/gst/inter/gstinteraudiosrc.h
+++ b/gst/inter/gstinteraudiosrc.h
@@ -21,6 +21,7 @@
#define _GST_INTER_AUDIO_SRC_H_
#include <gst/base/gstbasesrc.h>
+#include <gst/audio/audio.h>
#include "gstintersurface.h"
G_BEGIN_DECLS
@@ -43,6 +44,8 @@ struct _GstInterAudioSrc
guint64 n_samples;
int sample_rate;
+
+ const GstAudioFormatInfo *finfo;
};
struct _GstInterAudioSrcClass