ecore_audio: Guard against attaching an input twice

Add check in input_attach and change test case accordingly

Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
This commit is contained in:
Daniel Willmann 2013-04-19 16:41:17 +01:00
parent f12b3b94d0
commit 6781342d3c
3 changed files with 17 additions and 3 deletions

View File

@ -29,6 +29,12 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
in = eo_data_get(input, ECORE_AUDIO_OBJ_IN_CLASS);
if (ret)
*ret = EINA_FALSE;
if (in->output == eo_obj)
return;
if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input));
in->output = eo_obj;

View File

@ -116,6 +116,10 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
Eina_Bool ret;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret));
if (!ret)
return EINA_FALSE;
ss.format = PA_SAMPLE_FLOAT32LE;
eo_do(in, ecore_audio_obj_in_samplerate_get((int *)&ss.rate));
eo_do(in, ecore_audio_obj_in_speed_get(&speed));
@ -127,11 +131,10 @@ static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
stream = pa_stream_new(class_vars.context, name, &ss, NULL);
if (!stream) {
ERR("Could not create stream");
eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in));
return EINA_FALSE;
}
eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret));
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_SAMPLERATE_CHANGED, _update_samplerate_cb, eo_obj));
eo_do(in, eo_base_data_set("pulse_data", stream, NULL));

View File

@ -412,6 +412,7 @@ START_TEST(ecore_test_ecore_audio_obj_in_out)
{
Eo *out2;
Eina_List *in3;
Eina_Bool attached;
Eo *in = eo_add(ECORE_AUDIO_OBJ_IN_CLASS, NULL);
Eo *in2 = eo_add(ECORE_AUDIO_OBJ_IN_CLASS, NULL);
@ -429,7 +430,11 @@ START_TEST(ecore_test_ecore_audio_obj_in_out)
fail_if(eina_list_count(in3) != 0);
fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in, NULL)));
fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in, &attached)));
fail_if(!attached);
fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in, &attached)));
fail_if(attached);
fail_if(!eo_do(in, ecore_audio_obj_in_output_get(&out2)));