static void _stream_write_cb(void *handle, size_t len EINA_UNUSED, void *data)
{
- Eo *in = data;
- Ecore_Audio_Out_Tizen_Data *_td;
- _td = efl_key_data_get(in, "mod_data");
+ Ecore_Audio_Out_Tizen_Data *_td = data;
if (!_td) return;
void *buf;
_td->func->get_buffer_size(handle, &wlen);
buf = malloc(wlen);
- bread = ecore_audio_obj_in_read(in, buf, wlen);
+
+ //Guarantee Thread safety.
+ ecore_thread_main_loop_begin();
+ bread = ecore_audio_obj_in_read(_td->attached_in, buf, wlen);
+ ecore_thread_main_loop_end();
if (bread > 0)
{
free(buf);
}
+
+static Eina_Bool
+_is_input_attached(Eo *eo_obj, Eo *in)
+{
+ Ecore_Audio_Output *out_obj = efl_data_scope_get(eo_obj, ECORE_AUDIO_OUT_CLASS);
+ if (!out_obj->inputs) return EINA_FALSE;
+ return !!eina_list_data_find(out_obj->inputs, in);
+}
+
+
EOLIAN static Eina_Bool
_ecore_audio_out_tizen_ecore_audio_out_input_attach(Eo *eo_obj, Ecore_Audio_Out_Tizen_Data *_td, Eo *in)
{
int samplerate = 0;
int channels = 0;
+ if (_is_input_attached(eo_obj, in)) return EINA_TRUE;
+
ret2 = ecore_audio_obj_out_input_attach(efl_super(eo_obj, MY_CLASS), in);
if (!ret2)
return EINA_FALSE;
efl_key_data_set(in, "mod_data", _td);
efl_key_data_set(in, "pcm_fmt", strdup("S16"));
_td->attached_in = in;
- ret = _td->func->set_write_cb(handle, _stream_write_cb, in);
+ ret = _td->func->set_write_cb(handle, _stream_write_cb, _td);
if (ret)
{
ecore_audio_obj_out_input_detach(efl_super(eo_obj, MY_CLASS), in);
out = efl_add(ECORE_AUDIO_OUT_WASAPI_CLASS, NULL, efl_event_callback_add(efl_added, ECORE_AUDIO_OUT_WASAPI_EVENT_CONTEXT_FAIL, _out_fail, NULL));
# else
#if HAVE_TIZENAUDIO
- if (!(out = efl_add(ECORE_AUDIO_OUT_TIZEN_CLASS, NULL)))
+ if (!(out = efl_add_ref(ECORE_AUDIO_OUT_TIZEN_CLASS, NULL)))
{
ERR("Could not create multisense audio out (Tizen Audio)");
#endif