ecore_audio: Add return value to input_attach method

Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
This commit is contained in:
Daniel Willmann 2013-04-18 19:21:05 +01:00
parent 43299ade45
commit e99ab4623a
9 changed files with 29 additions and 17 deletions

View File

@ -66,7 +66,7 @@ main(int argc, const char *argv[])
eo_do(in, ecore_audio_obj_volume_set(0.7));
eo_do(in, ecore_audio_obj_vio_set(&vio, NULL, NULL));
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
ecore_main_loop_begin();

View File

@ -64,7 +64,7 @@ handle_cmd(char *cmd, size_t bread)
ecore_audio_obj_in_length_get(&length));
printf("Start: %s (%0.2fs)\n", name, length);
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
}
else
{
@ -83,7 +83,7 @@ handle_cmd(char *cmd, size_t bread)
ecore_audio_obj_in_length_get(&length));
printf("Start: %s (%0.2fs)\n", name, length);
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
}
}
else if (!strncmp(cmd, "l", bread))
@ -214,7 +214,7 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, Eo *in, const Eo_Event_D
eo_do(in, ecore_audio_obj_name_get(&name));
printf("Start: %s\n", name);
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
}
else
{
@ -296,7 +296,7 @@ main(int argc, const char *argv[])
printf("Start: %s (%0.2fs)\n", name, length);
out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
/* Disable canonical mode for stdin */

View File

@ -58,7 +58,7 @@ main(int argc, const char *argv[])
out = eo_add(ECORE_AUDIO_OBJ_OUT_SNDFILE_CLASS, NULL);
eo_do(out, ecore_audio_obj_source_set("foo.ogg"));
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
ecore_main_loop_begin();

View File

@ -25,6 +25,7 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
Ecore_Audio_Input *in;
Eo *input = va_arg(*list, Eo *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
in = eo_data_get(input, ECORE_AUDIO_OBJ_IN_CLASS);
@ -37,6 +38,8 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
obj->inputs = eina_list_append(obj->inputs, input);
if (ret)
*ret = EINA_TRUE;
}
static void _input_detach(Eo *eo_obj, void *_pd, va_list *list)

View File

@ -49,7 +49,7 @@ enum Ecore_Audio_Obj_Out_Sub_Ids
#define ECORE_AUDIO_OBJ_OUT_ID(sub_id) (ECORE_AUDIO_OBJ_OUT_BASE_ID + EO_TYPECHECK(enum Ecore_Audio_Obj_Out_Sub_Ids, sub_id))
#define ecore_audio_obj_out_input_attach(input) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_ATTACH), EO_TYPECHECK(Eo *, input)
#define ecore_audio_obj_out_input_attach(input, ret) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_ATTACH), EO_TYPECHECK(Eo *, input), EO_TYPECHECK(Eina_Bool *, ret)
#define ecore_audio_obj_out_input_detach(input) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_DETACH), EO_TYPECHECK(Eo *, input)

View File

@ -106,12 +106,13 @@ static Eina_Bool _update_samplerate_cb(void *data, Eo *eo_obj, const Eo_Event_De
pa_operation_unref(pa_stream_update_sample_rate(stream, samplerate * speed, NULL, NULL));
}
static void _input_attach_internal(Eo *eo_obj, Eo *in)
static Eina_Bool _input_attach_internal(Eo *eo_obj, Eo *in)
{
const char *name;
pa_sample_spec ss;
double speed;
pa_stream *stream;
Eina_Bool ret;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
ss.format = PA_SAMPLE_FLOAT32LE;
@ -125,10 +126,10 @@ static void _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");
return;
return EINA_FALSE;
}
eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in));
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));
@ -138,6 +139,8 @@ static void _input_attach_internal(Eo *eo_obj, Eo *in)
pa_stream_set_write_callback(stream, _write_cb, in);
pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_VARIABLE_RATE, NULL, NULL);
return ret;
}
static Eina_Bool _delayed_attach_cb(void *data, Eo *eo_obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
@ -152,14 +155,19 @@ static Eina_Bool _delayed_attach_cb(void *data, Eo *eo_obj, const Eo_Event_Descr
static void _input_attach(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
{
Eina_Bool retval = EINA_TRUE;
Eo *in = va_arg(*list, Eo *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (class_vars.state != PA_CONTEXT_READY) {
DBG("Delaying input_attach because PA context is not ready.");
eo_do(eo_obj, eo_event_callback_add(ECORE_AUDIO_EV_OUT_PULSE_CONTEXT_READY, _delayed_attach_cb, in));
} else {
_input_attach_internal(eo_obj, in);
retval = _input_attach_internal(eo_obj, in);
}
if (ret)
*ret = retval;
}
static void _drain_cb(pa_stream *stream, int success EINA_UNUSED, void *data EINA_UNUSED)

View File

@ -66,8 +66,9 @@ static void _input_attach(Eo *eo_obj, void *_pd, va_list *list)
Ecore_Audio_Output *out_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
Eo *in = va_arg(*list, Eo *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in));
eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, ret));
eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate));
eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels));

View File

@ -119,7 +119,7 @@ _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, c
if (!out)
out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
}
}
return EINA_TRUE;
@ -162,7 +162,7 @@ _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const
if (!out)
out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
}
}
return EINA_TRUE;

View File

@ -350,7 +350,7 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV));
eo_do(out, ecore_audio_obj_source_set(SOUNDS_DIR"/tmp.wav"));
eo_do(out, ecore_audio_obj_out_input_attach(in));
eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _finished_cb, NULL));
@ -407,7 +407,7 @@ 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)));
fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in, NULL)));
fail_if(!eo_do(in, ecore_audio_obj_in_output_get(&out2)));
@ -418,7 +418,7 @@ START_TEST(ecore_test_ecore_audio_obj_in_out)
fail_if(eina_list_count(in3) != 1);
fail_if(eina_list_data_get(in3) != in);
fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in2)));
fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in2, NULL)));
fail_if(!eo_do(out, ecore_audio_obj_out_inputs_get(&in3)));