GDateTime *time = g_date_time_new_now_local();
suffix = g_date_time_format(time, "%m%d_%H%M%S");
- dump_path = g_strdup_printf("%s_%dch_%dhz_%s.pcm", GST_PULSESINK_DUMP_INPUT_PATH_PREFIX, pbuf->channels, spec->rate, suffix);
-
+ dump_path = g_strdup_printf("%s%dch_%dhz_%s.pcm", GST_PULSESINK_DUMP_INPUT_PATH_PREFIX, pbuf->channels, spec->info.rate, suffix);
+ GST_WARNING_OBJECT(psink, "pulse-sink dumping enabled: dump path [%s]", dump_path);
psink->dump_fd_input = fopen(dump_path, "w+");
g_free(suffix);
}
#if defined(__TIZEN__) && defined(PCM_DUMP_ENABLE)
-static gboolean
-gst_pulsesink_pad_dump_handler (GstPad *pad, GstBuffer *buffer, gpointer data)
+static GstPadProbeReturn
+gst_pulsesink_pad_dump_probe (GstPad * pad, GstPadProbeInfo * info, gpointer data)
{
GstPulseSink *psink = GST_PULSESINK_CAST (data);
- int ret = -1;
-
- if (psink->dump_fd_input)
- ret = fwrite(GST_BUFFER_DATA(buffer), 1, GST_BUFFER_SIZE(buffer), psink->dump_fd_input);
-
- return !!ret;
+ size_t written = 0;
+ GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
+ GstMapInfo in_map;
+ if (psink->dump_fd_input) {
+ gst_buffer_map(buffer, &in_map, GST_MAP_READ);
+ written = fwrite(in_map.data, 1, in_map.size, psink->dump_fd_input);
+ if (written != in_map.size)
+ GST_WARNING("failed to write!!! ferror=%d", ferror(psink->dump_fd_input));
+ gst_buffer_unmap(buffer, &in_map);
+ }
+ return GST_PAD_PROBE_OK;
}
#endif /* __TIZEN__ && PCM_DUMP_ENABLE */
if (pulsesink->need_dump_input) {
sinkpad = gst_element_get_static_pad((GstElement *)pulsesink, "sink");
if (sinkpad) {
- gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (gst_pulsesink_pad_dump_handler), pulsesink);
+ gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_BUFFER, gst_pulsesink_pad_dump_probe, pulsesink, NULL);
gst_object_unref (GST_OBJECT(sinkpad));
}
}
#include "pulsesrc.h"
#include "pulseutil.h"
+#ifdef __TIZEN__
+#ifdef PCM_DUMP_ENABLE
+#include <vconf.h>
+#endif
+#endif
+
GST_DEBUG_CATEGORY_EXTERN (pulse_debug);
#define GST_CAT_DEFAULT pulse_debug
PROP_LAST
};
+#ifdef __TIZEN__
+#ifdef PCM_DUMP_ENABLE
+#define GST_PULSESRC_DUMP_VCONF_KEY "memory/private/sound/pcm_dump"
+#define GST_PULSESRC_DUMP_OUTPUT_PATH_PREFIX "/tmp/dump_pulsesrc_out"
+#define GST_PULSESRC_DUMP_OUTPUT_FLAG 0x00200000U
+#endif
+#endif
+
static void gst_pulsesrc_destroy_stream (GstPulseSrc * pulsesrc);
static void gst_pulsesrc_destroy_context (GstPulseSrc * pulsesrc);
#endif /* __TIZEN__ */
}
+#ifdef __TIZEN__
+#ifdef PCM_DUMP_ENABLE
+static GstPadProbeReturn
+gst_pulsesrc_pad_dump_probe (GstPad *pad, GstPadProbeInfo * info, gpointer data)
+{
+ GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (data);
+ size_t written = 0;
+ GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
+ GstMapInfo in_map;
+ if (pulsesrc->dump_fd_output) {
+ gst_buffer_map(buffer, &in_map, GST_MAP_READ);
+ written = fwrite(in_map.data, 1, in_map.size, pulsesrc->dump_fd_output);
+ if (written != in_map.size)
+ GST_WARNING("failed to write!!! ferror=%d", ferror(pulsesrc->dump_fd_output));
+ gst_buffer_unmap(buffer, &in_map);
+ }
+ return GST_PAD_PROBE_OK;
+}
+#endif
+#endif
+
static void
gst_pulsesrc_init (GstPulseSrc * pulsesrc)
{
+#ifdef __TIZEN__
+#ifdef PCM_DUMP_ENABLE
+ GstPad *srcpad = NULL;
+ int vconf_dump = 0;
+#endif
+#endif
pulsesrc->server = NULL;
pulsesrc->device = NULL;
pulsesrc->client_name = gst_pulse_client_name ();
pulsesrc->latency = g_strdup (DEFAULT_AUDIO_LATENCY);
pulsesrc->proplist = pa_proplist_new();
pa_proplist_sets(pulsesrc->proplist, PA_PROP_MEDIA_TIZEN_AUDIO_LATENCY, pulsesrc->latency);
-#endif /* __TIZEN__ */
+#ifdef PCM_DUMP_ENABLE
+ if (vconf_get_int(GST_PULSESRC_DUMP_VCONF_KEY, &vconf_dump)) {
+ GST_WARNING("vconf_get_int %s failed", GST_PULSESRC_DUMP_VCONF_KEY);
+ }
+ pulsesrc->need_dump_output = vconf_dump & GST_PULSESRC_DUMP_OUTPUT_FLAG ? TRUE : FALSE;
+ pulsesrc->dump_fd_output = NULL;
+ if (pulsesrc->need_dump_output) {
+ srcpad = gst_element_get_static_pad((GstElement *)pulsesrc, "src");
+ gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BUFFER, gst_pulsesrc_pad_dump_probe, pulsesrc, NULL);
+ }
+#endif /* PCM_DUMP_ENABLE */
+#endif /* __TIZEN__ */
/* this should be the default but it isn't yet */
gst_audio_base_src_set_slave_method (GST_AUDIO_BASE_SRC (pulsesrc),
GST_AUDIO_BASE_SRC_SLAVE_SKEW);
pa_threaded_mainloop_lock (pulsesrc->mainloop);
gst_pulsesrc_destroy_context (pulsesrc);
pa_threaded_mainloop_unlock (pulsesrc->mainloop);
-
+#ifdef __TIZEN__
+#ifdef PCM_DUMP_ENABLE
+ if (pulsesrc->dump_fd_output) {
+ fclose(pulsesrc->dump_fd_output);
+ pulsesrc->dump_fd_output = NULL;
+ }
+#endif
+#endif
return TRUE;
}
gst_pulsesrc_set_stream_volume (pulsesrc, pulsesrc->volume);
pulsesrc->volume_set = FALSE;
}
+#ifdef __TIZEN__
+#ifdef PCM_DUMP_ENABLE
+ if (pulsesrc->need_dump_output) {
+ char *suffix , *dump_path;
+ GDateTime *time = NULL;
+ if (pulsesrc->dump_fd_output) {
+ fclose(pulsesrc->dump_fd_output);
+ pulsesrc->dump_fd_output = NULL;
+ }
+ time = g_date_time_new_now_local();
+ suffix = g_date_time_format(time, "%m%d_%H%M%S");
+ dump_path = g_strdup_printf("%s_%dch_%dhz_%s.pcm", GST_PULSESRC_DUMP_OUTPUT_PATH_PREFIX, pulsesrc->sample_spec.channels, pulsesrc->sample_spec.rate, suffix);
+ GST_WARNING_OBJECT(asrc,"pulse-source dumping enabled: dump path [%s]", dump_path);
+ pulsesrc->dump_fd_output = fopen(dump_path, "w+");
+
+ g_free(suffix);
+ g_free(dump_path);
+ g_date_time_unref(time);
+ }
+#endif /* PCM_DUMP_ENABLE */
+#endif
/* get the actual buffering properties now */
actual = pa_stream_get_buffer_attr (pulsesrc->stream);