mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
interaudiosrc: make silence memory actually contain silence
instead of random data. Reported by Marco Micheletti on gstreamer-devel.
This commit is contained in:
parent
9d92aaabe7
commit
e861c72efc
2 changed files with 20 additions and 5 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue