📄 mmivoicememo.c
字号:
else
{
//Display a dialog and exit
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_start_playback failed with return value : %d", mfw_aud_retVal);
voice_memo_dialog_create( win, TxtPlayback, TxtFailed);
}
}
}
else if (value EQ VM_RECORD)
{
TRACE_FUNCTION ("VM_RECORD()");
mfw_aud_retVal = mfw_aud_vm_start_record(VOICE_MEMO_MAX_DURATION, voice_memo_riv_record_cb);
// If the Riviera call failed
if (mfw_aud_retVal == MFW_AUD_VM_OK)
{
//start the second timer
data->time = 0;
tim_start (data->info_tim);
}
else
{
if (mfw_aud_retVal == MFW_AUD_VM_MEM_FULL)
{
TRACE_EVENT ("memory full ");
//play Keybeep
audio_PlaySoundID(0, TONES_KEYBEEP, 200, 0 );
voice_memo_dialog_create( win, TxtRecording, TxtFull );
}
else
{
//Display a dialog and exit
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_start_record failed with return value : %d", mfw_aud_retVal);
voice_memo_dialog_create( win, TxtRecording, TxtFailed );
}
}
}
win_show (win);
break;
//if the user selected to clear the Voicememo buffer
case VM_DELETE_BUFFER:
voice_memo_dialog_create( win, TxtDeleted, TxtNull );
/*
** Delete the voice memo file
*/
mfw_aud_vm_delete_file();
break;
case VM_DESTROY:
voice_memo_destroy(win);
break;
}
}
/*******************************************************************************
$Function: voice_memo_win_cb
$Description: Callback function for information dialog
$Returns: void
$Arguments: window handle event, win
*******************************************************************************/
static int voice_memo_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
{
T_voice_memo * data = (T_voice_memo *)win->user;
TRACE_FUNCTION ("voice_memo_win_cb()");
if (data EQ 0)
return 1;
switch (event)
{
case E_WIN_VISIBLE:
if (win->flags & E_WIN_VISIBLE)
{
/*
* Clear Screen
*/
dspl_ClearAll();
switch (data->Identifier)
{
case VM_PLAY:
/*
* Print the information screen
*/
ALIGNED_PROMPT(LEFT,Mmi_layout_line(1),0, TxtPlayback);
/*
* Print the elapsed time
*/
displayAlignedText(LEFT, Mmi_layout_line(2), 0, data->elapsed_time);
/*
* Print softkeys
*/
displaySoftKeys(TxtDelete, data->play_sk2);
break;
case VM_RECORD:
/*
* Print the information screen
*/
ALIGNED_PROMPT(LEFT,Mmi_layout_line(1),0, TxtRecording);
/*
* Print the elapsed time
*/
displayAlignedText(LEFT, Mmi_layout_line(2), 0, data->elapsed_time);
/*
* Print softkeys
*/
displaySoftKeys(TxtStop, '\0');
break;
}
}
break;
default:
return 0;
}
return 1;
}
/*******************************************************************************
$Function: voice_memo_tim_cb
$Description: Callback function for the voice_memo timer.
$Returns: MFW event handler
$Arguments: window handle event, timer control block
*******************************************************************************/
static T_MFW_CB voice_memo_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_voice_memo * data = (T_voice_memo *)win_data->user;
SHORT mfw_aud_retVal;
char buf[40];
TRACE_FUNCTION ("voice_memo_tim_cb()");
switch (data->Identifier)
{
case VM_PLAY:
//the max. playback time is 10 second
if (data->time < mfw_aud_vm_get_duration())
{
TRACE_EVENT ("continue the second timer");
data->time ++;
// it shows here the elapsed time
sprintf(data->elapsed_time,"%02d sec", data->time);
TRACE_EVENT (data->elapsed_time);
//continue the second timer
tim_start (data->info_tim);
}
else
{
data->play_sk2 = TxtSoftBack;
#ifndef _SIMULATION_
/*
** Stop playing the Voice Memo.
*/
mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
if (mfw_aud_retVal != MFW_AUD_VM_OK)
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_playback failed with return value : %d", mfw_aud_retVal);
#else
TRACE_EVENT("call mfw_aud_vm_stop_playback()");
#endif
}
break;
case VM_RECORD:
data->time++;
if (data->time < VOICE_MEMO_MAX_DURATION)
{
TRACE_EVENT ("continue the second timer");
// it shows here the remainig time
sprintf(data->elapsed_time,"%02d sec", (VOICE_MEMO_MAX_DURATION - data->time));
TRACE_EVENT (data->elapsed_time);
//continue the second timer
tim_start (data->info_tim);
}
else
{
mfw_aud_vm_set_duration(VOICE_MEMO_MAX_DURATION);
#ifndef _SIMULATION_
/*
** Stop recording the Voice Memo.
*/
mfw_aud_retVal = mfw_aud_vm_stop_record(voice_memo_riv_record_cb);
if (mfw_aud_retVal != MFW_AUD_VM_OK)
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_record failed with return value : %d", mfw_aud_retVal);
//the voice memo is now full, show "memory full"
audio_PlaySoundID(0, TONES_KEYBEEP, 200, 0 );
voice_memo_dialog_create( win, TxtRecording, TxtFull );
#else
TRACE_EVENT("call mfw_aud_vm_stop_record()");
#endif
}
break;
}
//Update the screen
winShow(win);
return 0;
}
/*******************************************************************************
$Function: voice_memo_kbd_cb
$Description: Keyboard event handler
$Returns: status int
$Arguments: window handle event, keyboard control block
*******************************************************************************/
static int voice_memo_kbd_cb (T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_voice_memo * data = (T_voice_memo *)win_data->user;
USHORT Identifier = data->Identifier;
SHORT mfw_aud_retVal;
TRACE_FUNCTION("voice_memo_kbd_cb");
switch (keyboard->code)
{
case KCD_HUP:
case KCD_LEFT:
if (Identifier EQ VM_PLAY)
{
#ifndef _SIMULATION_
/*
** Stop playing the Voice Memo and Delete it.
*/
mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
if (mfw_aud_retVal != MFW_AUD_VM_OK)
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_playback failed with return value : %d", mfw_aud_retVal);
#else
TRACE_EVENT("call mfw_aud_vm_stop_playback()");
#endif
//delete the voicememo buffer
mfw_aud_vm_set_duration(0);
//user selected the delete-key
SEND_EVENT (win, VM_DELETE_BUFFER, 0, 0);
}
else if (Identifier EQ VM_RECORD)
{
mfw_aud_vm_set_duration(data->time);
#ifndef _SIMULATION_
/*
** Stop recording the Voice Memo.
*/
mfw_aud_retVal = mfw_aud_vm_stop_record(voice_memo_riv_record_cb);
if (mfw_aud_retVal != MFW_AUD_VM_OK)
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_record failed with return value : %d", mfw_aud_retVal);
//go back to the previous dialog
SEND_EVENT (win, VM_DESTROY, 0, 0);
#else
TRACE_EVENT("call mfw_aud_vm_stop_record()");
#endif
}
break;
case KCD_RIGHT:
if (Identifier EQ VM_PLAY)
{
#ifndef _SIMULATION_
/*
** Stop playing the Voice Memo.
*/
mfw_aud_retVal = mfw_aud_vm_stop_playback(voice_memo_riv_play_cb);
if (mfw_aud_retVal != MFW_AUD_VM_OK)
TRACE_EVENT_P1 ("ERROR : mfw_aud_vm_stop_playback failed with return value : %d", mfw_aud_retVal);
#else
TRACE_EVENT("call mfw_aud_vm_stop_playback()");
#endif
//go back to the previous dialog
SEND_EVENT (win, VM_DESTROY, 0, 0);
}
else if (Identifier EQ VM_RECORD)
{
//nothing
}
break;
default:
break;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: voice_memo_dialog_cb
$Description:
$Returns:
$Arguments:
*******************************************************************************/
void voice_memo_dialog_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
{
TRACE_FUNCTION ("voice_memo_dialog_cb()");
switch (reason)
{
case INFO_KCD_LEFT:
/* no break; */
case INFO_TIMEOUT:
/* no break; */
case INFO_KCD_HUP:
/* no break; */
case INFO_KCD_RIGHT:
/* no break; */
case INFO_KCD_CLEAR:
//go back to the previous dialog
SEND_EVENT (win, VM_DESTROY,0, 0);
break;
}
}
/*******************************************************************************
$Function: voice_memo_dialog_create
$Description:
$Returns:
$Arguments:
*******************************************************************************/
static void voice_memo_dialog_create(T_MFW_HND win, int str1, int str2)
{
T_DISPLAY_DATA display_info;
TRACE_FUNCTION ("voice_memo_dialog_create()");
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, str1, str2, COLOUR_STATUS);
dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)voice_memo_dialog_cb, THREE_SECS, KEY_CLEAR | KEY_RIGHT | KEY_LEFT );
/*
* Call Info Screen
*/
info_dialog (win, &display_info);
}
static void voice_memo_riv_record_cb(void *parameter)
{
T_AUDIO_VM_RECORD_STATUS *record_status;
record_status = (T_AUDIO_VM_RECORD_STATUS *)parameter;
if (record_status->status != AUDIO_OK)
{
TRACE_EVENT_P1("ERROR : voice_memo_riv_play_cb received AUDIO_ERROR, recorded duration is %d",
record_status->recorded_duration);
}
else
{
TRACE_EVENT_P1("INFO : voice_memo_riv_play_cb received AUDIO_OK, recorded duration is %d",
record_status->recorded_duration);
mfw_aud_vm_set_duration((UINT8)record_status->recorded_duration);
}
}
static void voice_memo_riv_play_cb(void *parameter)
{
T_AUDIO_VM_PLAY_STATUS *play_status;
play_status = (T_AUDIO_VM_PLAY_STATUS *)parameter;
if (play_status->status != AUDIO_OK)
{
TRACE_EVENT("ERROR : voice_memo_riv_play_cb received AUDIO_ERROR");
}
else
{
TRACE_EVENT("INFO : voice_memo_riv_play_cb received AUDIO_OK");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -