Languages

Menu
Sites
Language
Audio recorder invalid operation on wearable

I need to record voice from mic and save it to file. Recording runs in background service. Everything works fine, until I call recorder_commit, then I get an error   

recorder.c: __convert_recorder_error_code(193) > [recorder_commit] INVALID_OPERATION(0xffffffda) : core frameworks error code(0x80000816)

file is created in storage, but it has size of 0 bytes.
this is my code (stripped from logs and error code checking)

Recorder create and start        

        recorder_create_audiorecorder(&recorder);
        ...
        snprintf(filename, sizeof(filename), "%s/recording-%02i%02i%02i_%02i%02i%02i.amr",
                        app_get_data_path(),
                        localtime.tm_year - 100, localtime.tm_mon + 1, localtime.tm_mday,
                        localtime.tm_hour, localtime.tm_min, localtime.tm_sec);
        ...
        recorder_set_filename(recorder, filename);
        recorder_set_file_format(recorder, RECORDER_FILE_FORMAT_AMR);
        recorder_attr_set_audio_encoder_bitrate(recorder, 28800);
        recorder_attr_set_audio_device(recorder, RECORDER_AUDIO_DEVICE_MIC);
        recorder_attr_set_audio_samplerate(recorder, 44100);
        recorder_attr_set_size_limit(recorder, 1024 * 100);
        ...
        recorder_prepare(recorder);
        recorder_start(recorder);


Recorder stop and destroy

        recorder_state_e state;
        int error_code = recorder_get_state(recorder, &state);

        if(state == RECORDER_STATE_RECORDING)
        {
            //I get error in both of these calls
            //recorder_pause(recorder);
            recorder_commit(recorder);
        }

        recorder_unprepare(recorder);
        recorder_destroy(recorder);

I have also set privileges

    mediastorage
    recorder

Any help would be appreciated, thanks

Edited by: Vydra on 09 May, 2017

Responses

6 Replies
Armaan-Ul- Islam

# First of all, Hope you successfully met the Preconditions mentioned on the API Reference.

https://developer.tizen.org/ko/development/api-references/native-application?redirect=/dev-guide/2.3.1/org.tizen.native.mobile.apireference/group__CAPI__MEDIA__RECORDER__MODULE.html#gaf5361505237ecb2e1c6a9d565bcaeb20

https://developer.tizen.org/ko/development/api-references/native-application?redirect=/dev-guide/2.3.1/org.tizen.native.mobile.apireference/group__CAPI__MEDIA__RECORDER__MODULE.html&langredirect=1#ga5bcd6e4fdb95adeef17cbc5cc8453195

 

## I guess what you have shared is pseudo code. But is it the is issue that, the very moment recorder_state is RECORDER_STATE_RECORDING (Recorder is recording media) you are calling a recorder_commit() ?? I mean may be in .001ms ( just an example timeframe ), In that case the file should be 0 byte naturally.

Add some button event (or something alternative) to trigger commit function when user will trigger end  of recording (may be after couple of minites).

 

### recorder_commit() function returns 0 on success, otherwise it returns the error code. Catch the Error Code to detect the error and debug thereby. Example:

 

int error_code; 

error_code = recorder_commit(recorder_h);

dlog_print(DLOG_ERROR, LOG_TAG, "Error code on recorder_commit() = %d", error_code);

if(error_code==RECORDER_ERROR_NONE){
    // Successful 
}

if(error_code==RECORDER_ERROR_INVALID_PARAMETER){
    //Invalid parameter 
}

if(error_code==RECORDER_ERROR_INVALID_OPERATION){
    //Invalid operation 
}

if(error_code==RECORDER_ERROR_INVALID_STATE){
    //Invalid state
}

if(error_code==RECORDER_ERROR_PERMISSION_DENIED){
    //The access to the resources can not be granted
}

if(error_code==RECORDER_ERROR_NOT_SUPPORTED){
    //The feature is not supported 
}

 

Tizen is me

Hi, I got 

RECORDER_ERROR_INVALID_OPERATION

do you know why is this happening, thanks 

Tizen is me

Edit : this happening using button to stop recording

Armaan-Ul- Islam

That means:

button to stop recording refers to ---> recorder_commit()

right?

Revise again if you have met the Preconditions and Privileges required. And this link says:

RECORDER_ERROR_INVALID_OPERATION  --->

Internal error

https://developer.tizen.org/development/api-references/native-application?redirect=/dev-guide/3.0.0/org.tizen.native.wearable.apireference/group__CAPI__MEDIA__RECORDER__MODULE.html#gga9edb84cd056c6c6e09190e924f0a2617a42db15776531b785f88d59d966c0722c

 

In that case, Check out if this response helps:

https://developer.tizen.org/forums/native-application-development/native-audio-recording-0#comment-24830

Armaan-Ul- Islam

Seems solved as "And the problem is only occurs in the emulator, when tried it on device it works flawlessly" Says this post...

https://developer.tizen.org/forums/native-application-development/native-audio-recording-0

 

In addition: Tizen Native Guide of media recording states:

During testing, you can use the emulator to imitate audio or video recording, as long as your computer has a proper input source device.

https://developer.tizen.org/development/guides/native-application/media-and-camera/media-recording

So I guess You must have 'Microphone device' (Integrated with headphone or laptop)  working to record media.

Tizen is me

Yes, I think thats correct