int
main(int argc, const char *argv[])
{
+ Eina_Bool ret;
+
ecore_init();
ecore_audio_init();
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, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret) {
+ printf("Could not attach input");
+ goto end;
+ }
ecore_main_loop_begin();
const char *name;
Eina_List *out_inputs, *input;
Eo *in;
- Eina_Bool paused;
+ Eina_Bool paused, ret;
double pos, length;
int min;
else if (!strncmp(cmd, "n", bread))
{
in = eina_list_data_get(out_inputs);
- eo_do(out, ecore_audio_obj_out_input_detach(in));
+ eo_do(out, ecore_audio_obj_out_input_detach(in, &ret));
+ if (!ret)
+ printf("Could not detach input\n");
+
inputs = eina_list_remove(inputs, in);
if (eina_list_count(inputs) > 0)
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, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret)
+ printf("Could not attach input %s\n", name);
}
else
{
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, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret)
+ printf("Could not attach input %s\n", name);
}
}
else if (!strncmp(cmd, "l", bread))
static Eina_Bool _play_finished(void *data EINA_UNUSED, Eo *in, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
const char *name;
+ Eina_Bool ret;
eo_do(in, ecore_audio_obj_name_get(&name));
printf("Done: %s\n", name);
inputs = eina_list_remove(inputs, in);
- eo_do(out, ecore_audio_obj_out_input_detach(in));
+ eo_do(out, ecore_audio_obj_out_input_detach(in, &ret));
eo_del(in);
+ if (!ret)
+ printf("Could not detach input %s\n", name);
+
if (eina_list_count(inputs) > 0)
{
eo_do(in, ecore_audio_obj_name_get(&name));
printf("Start: %s\n", name);
- eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret)
+ printf("Could not attach input %s\n", name);
}
else
{
{
int i, freq;
+ Eina_Bool ret;
struct termios tcorig, tcnew;
Eo *in;
char *tmp, *tmp2, *val;
tmp = strdup(argv[i]);
eo_do(in, ecore_audio_obj_name_set(basename(tmp)));
free(tmp);
- eo_do(in, ecore_audio_obj_source_set(argv[i]));
+ eo_do(in, ecore_audio_obj_source_set(argv[i], &ret));
+ if (!ret) {
+ printf("Could not set %s as input\n", argv[i]);
+ continue;
+ }
}
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL));
inputs = eina_list_append(inputs, in);
double length;
in = (Eo *)eina_list_data_get(inputs);
+ if (!in)
+ return 1;
+
eo_do(in, ecore_audio_obj_name_get(&name),
ecore_audio_obj_in_length_get(&length));
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, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret)
+ printf("Could not attach input %s\n", name);
/* Disable canonical mode for stdin */
{
Eo *out;
Eo *in;
+ Eina_Bool ret;
if (argc < 2)
{
in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
eo_do(in, ecore_audio_obj_name_set(basename(argv[1])));
- eo_do(in, ecore_audio_obj_source_set(argv[1]));
+ eo_do(in, ecore_audio_obj_source_set(argv[1], &ret));
+ if (!ret) {
+ printf("Could not set %s as input\n", argv[1]);
+ eo_del(in);
+ return 1;
+ }
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _play_finished, NULL));
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, NULL));
+ eo_do(out, ecore_audio_obj_source_set("foo.ogg", &ret));
+ if (!ret) {
+ printf("Could not set %s as output\n", "foo.ogg");
+ eo_del(in);
+ eo_del(out);
+ return 1;
+ }
+
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret) {
+ printf("Could not attach input\n");
+ eo_del(out);
+ eo_del(in);
+ return 1;
+ }
ecore_main_loop_begin();
#define ecore_audio_obj_volume_get(ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_VOLUME_GET), EO_TYPECHECK(double *, ret)
-#define ecore_audio_obj_source_set(source) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_SET), EO_TYPECHECK(const char *, source)
+#define ecore_audio_obj_source_set(source, ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_SET), EO_TYPECHECK(const char *, source), EO_TYPECHECK(Eina_Bool *, ret)
#define ecore_audio_obj_source_get(source) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_SOURCE_GET), EO_TYPECHECK(const char **, source)
-#define ecore_audio_obj_format_set(format) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_SET), EO_TYPECHECK(Ecore_Audio_Format, format)
+#define ecore_audio_obj_format_set(format, ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_SET), EO_TYPECHECK(Ecore_Audio_Format, format), EO_TYPECHECK(Eina_Bool *, ret)
#define ecore_audio_obj_format_get(ret) ECORE_AUDIO_OBJ_ID(ECORE_AUDIO_OBJ_SUB_ID_FORMAT_GET), EO_TYPECHECK(Ecore_Audio_Format *, ret)
Ecore_Audio_Input *obj = _pd;
if(obj->output)
- eo_do(obj->output, ecore_audio_obj_out_input_detach(eo_obj));
+ eo_do(obj->output, ecore_audio_obj_out_input_detach(eo_obj, NULL));
eo_do_super(eo_obj, MY_CLASS, eo_destructor());
}
Ecore_Audio_Input *in_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_IN_CLASS);
const char *source = va_arg(*list, const char *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+
+ if (ret)
+ *ret = EINA_FALSE;
if (obj->handle) {
sf_close(obj->handle);
return;
}
+ if (ret)
+ *ret = EINA_TRUE;
+
in_obj->seekable = EINA_TRUE;
in_obj->length = (double)obj->sfinfo.frames / obj->sfinfo.samplerate;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (ea_obj->source) {
ERR("Input is already open - cannot change format");
break;
default:
ERR("Format not supported!");
+ if (ret)
+ *ret = EINA_FALSE;
return;
}
ea_obj->format = format;
+
+ if (ret)
+ *ret = EINA_TRUE;
}
static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
if (in->output == eo_obj)
return;
- if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input));
+ if (in->output) eo_do(in->output, ecore_audio_obj_out_input_detach(input, NULL));
in->output = eo_obj;
/* TODO: Check type is input
*ret = EINA_TRUE;
}
-static void _input_detach(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
+static void _input_detach(Eo *eo_obj, void *_pd, va_list *list)
{
Ecore_Audio_Output *obj = _pd;
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);
+ if (ret)
+ *ret = EINA_FALSE;
+
+ if (in->output != eo_obj)
+ return;
+
in->output = NULL;
/* TODO: Check type is input
obj->inputs = eina_list_remove(obj->inputs, input);
+ if (ret)
+ *ret = EINA_TRUE;
}
static void _inputs_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
Eo *in;
EINA_LIST_FOREACH_SAFE(obj->inputs, cur, tmp, in) {
- eo_do(eo_obj, ecore_audio_obj_out_input_detach(in));
+ eo_do(eo_obj, ecore_audio_obj_out_input_detach(in, NULL));
}
eo_do_super(eo_obj, MY_CLASS, eo_destructor());
#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)
+#define ecore_audio_obj_out_input_detach(input, ret) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUT_DETACH), EO_TYPECHECK(Eo *, input), EO_TYPECHECK(Eina_Bool *, ret)
#define ecore_audio_obj_out_inputs_get(input) ECORE_AUDIO_OBJ_OUT_ID(ECORE_AUDIO_OBJ_OUT_SUB_ID_INPUTS_GET), EO_TYPECHECK(Eina_List **, input)
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));
+ eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL));
return EINA_FALSE;
}
static void _input_detach(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
{
pa_stream *stream;
+ Eina_Bool ret2;
Eo *in = va_arg(*list, Eo *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+
+ if (ret)
+ *ret = EINA_FALSE;
+
+ eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, &ret2));
+ if (!ret2)
+ return;
eo_do(in, eo_base_data_get("pulse_data", (void **)&stream));
pa_stream_set_write_callback(stream, NULL, NULL);
pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL));
- eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in));
+ if (ret)
+ *ret = EINA_TRUE;
}
static void _state_cb(pa_context *context, void *data EINA_UNUSED)
Ecore_Audio_Sndfile *obj = _pd;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
Ecore_Audio_Output *out_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_OUT_CLASS);
+ Eina_Bool ret2;
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, ret));
+ if (ret)
+ *ret = EINA_FALSE;
+
+ eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_attach(in, &ret2));
+ if (!ret2)
+ return;
eo_do(in, ecore_audio_obj_in_samplerate_get(&obj->sfinfo.samplerate));
eo_do(in, ecore_audio_obj_in_channels_get(&obj->sfinfo.channels));
if (!obj->handle) {
eina_stringshare_del(ea_obj->source);
ea_obj->source = NULL;
+ eo_do_super(eo_obj, MY_CLASS, ecore_audio_obj_out_input_detach(in, NULL));
return;
}
+ if (ret)
+ *ret = EINA_TRUE;
+
if (ea_obj->paused)
return;
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
const char *source = va_arg(*list, const char *);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
+
+ if (ret)
+ *ret = EINA_FALSE;
if (obj->handle) {
sf_close(obj->handle);
if (!ea_obj->source)
return;
+ //FIXME: Open the file here
+
+ if (ret)
+ *ret = EINA_TRUE;
+
}
static void _source_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
Ecore_Audio_Object *ea_obj = eo_data_get(eo_obj, ECORE_AUDIO_OBJ_CLASS);
Ecore_Audio_Format format= va_arg(*list, Ecore_Audio_Format);
+ Eina_Bool *ret = va_arg(*list, Eina_Bool *);
if (ea_obj->source) {
ERR("Input is already open - cannot change format");
+ if (ret)
+ *ret = EINA_FALSE;
return;
}
break;
default:
ERR("Format not supported!");
+ if (ret)
+ *ret = EINA_FALSE;
return;
}
ea_obj->format = format;
+ if (ret)
+ *ret = EINA_TRUE;
}
static void _format_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
{
eo_do_super(eo_obj, MY_CLASS, eo_constructor());
- eo_do(eo_obj, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG));
+ eo_do(eo_obj, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_OGG, NULL));
}
static void _destructor(Eo *eo_obj, void *_pd, va_list *list EINA_UNUSED)
Edje_Sound_Sample *sample;
char snd_id_str[255];
int i;
+ Eina_Bool ret;
if (!sample_name)
{
if (!out)
out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
- eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret) {
+ ERR("Could not attach input");
+ eo_del(in);
+ return EINA_FALSE;
+ }
}
}
return EINA_TRUE;
#ifdef ENABLE_MULTISENSE
unsigned int i;
Edje_Sound_Tone *tone;
+ Eina_Bool ret;
Eo *in;
if (!tone_name)
{
- ERR("Given Tone Name is NULL\n");
+ ERR("Given Tone Name is NULL");
return EINA_FALSE;
}
if ((!ed) || (!ed->file) || (!ed->file->sound_dir))
if (!out)
out = eo_add(ECORE_AUDIO_OBJ_OUT_PULSE_CLASS, NULL);
- eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ if (!ret) {
+ ERR("Could not attach input");
+ eo_del(in);
+ return EINA_FALSE;
+ }
}
}
return EINA_TRUE;
Eo *in, *out;
double len;
int channel, rate, freq;
+ Eina_Bool ret;
in = eo_add(ECORE_AUDIO_OBJ_IN_TONE_CLASS, NULL);
fail_if(!in);
fail_if(!out);
eo_do(out, ecore_audio_obj_name_set("tmp.wav"));
- eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV));
- eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav"));
+ eo_do(out, ecore_audio_obj_format_set(ECORE_AUDIO_FORMAT_WAV, &ret));
+ fail_if(!ret);
+ eo_do(out, ecore_audio_obj_source_set(TESTS_BUILD_DIR"/tmp.wav", &ret));
+ fail_if(!ret);
- eo_do(out, ecore_audio_obj_out_input_attach(in, NULL));
+ eo_do(out, ecore_audio_obj_out_input_attach(in, &ret));
+ fail_if(!ret);
eo_do(in, eo_event_callback_add(ECORE_AUDIO_EV_IN_STOPPED, _finished_cb, NULL));
Eo *in;
double len, rem;
int channel, rate;
+ Eina_Bool ret;
in = eo_add(ECORE_AUDIO_OBJ_IN_SNDFILE_CLASS, NULL);
fail_if(!in);
eo_do(in, ecore_audio_obj_name_set("sms.ogg"));
- eo_do(in, ecore_audio_obj_source_set(TESTS_SRC_DIR"/sms.ogg"));
+ eo_do(in, ecore_audio_obj_source_set(TESTS_SRC_DIR"/sms.ogg", &ret));
+ fail_if(!ret);
eo_do(in, ecore_audio_obj_in_channels_get(&channel));
fail_if(channel != 2);
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, NULL)));
+ fail_if(!eo_do(out, ecore_audio_obj_out_input_attach(in2, &attached)));
+ fail_if(!attached);
fail_if(!eo_do(out, ecore_audio_obj_out_inputs_get(&in3)));
tcase_add_test(tc, ecore_test_ecore_audio_obj);
tcase_add_test(tc, ecore_test_ecore_audio_obj_in);
tcase_add_test(tc, ecore_test_ecore_audio_obj_in_out);
- tcase_add_test(tc, ecore_test_ecore_audio_obj_sndfile);
tcase_add_test(tc, ecore_test_ecore_audio_obj_tone);
+#ifdef HAVE_SNDFILE
+ tcase_add_test(tc, ecore_test_ecore_audio_obj_sndfile);
+#endif
+#ifdef HAVE_PUSE
+ tcase_add_test(tc, ecore_test_ecore_audio_obj_pulse);
+#endif
+
/*
tcase_add_test(tc, ecore_test_ecore_audio_default);
tcase_add_test(tc, ecore_test_ecore_audio_sndfile_vio);