1 /*---------------------------------------------------------------------------* 2 * SR_EventLogImpl.h * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20 #ifndef __SR_EventLogIMPL_H 21 #define __SR_EventLogIMPL_H 22 23 24 25 #include <stdlib.h> 26 #include "ESR_ReturnCode.h" 27 #include "ESR_SessionTypeListener.h" 28 29 #define TOK_BUFLEN (2*P_PATH_MAX) 30 #define MAX_LOG_RECORD (16*1024) 31 32 /** 33 * EventLog implementation. 34 */ 35 36 typedef enum 37 { 38 FILE_OK, 39 SPACE_SETTING, 40 UNINITIALIZED, 41 NO_FILE, 42 FILE_ERROR, 43 SEEK_ERROR 44 } EventLogFileState; 45 46 typedef struct SR_EventLogImpl_t 47 { 48 /** 49 * Interface functions that must be implemented. 50 */ 51 SR_EventLog Interface; 52 53 LCHAR tokenBuf[MAX_LOG_RECORD]; 54 55 long serviceStartUserCPU; 56 long serviceStartKernelCPU; 57 58 EventLogFileState logFile_state; 59 ESR_SessionTypeListener sessionListener; 60 ESR_SessionTypeListenerPair sessionListenerPair; 61 62 PFile* logFile; 63 size_t logLevel; 64 LCHAR logFilename[P_PATH_MAX]; 65 LCHAR waveformFilename[P_PATH_MAX]; 66 PFile* waveformFile; 67 size_t waveformCounter; 68 size_t waveform_num_bytes; 69 size_t waveform_sample_rate; 70 size_t waveform_bytes_per_sample; 71 } 72 SR_EventLogImpl; 73 74 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_Destroy(SR_EventLog* self); 75 76 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_Token(SR_EventLog* self, const LCHAR* token, const LCHAR *value); 77 78 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenInt(SR_EventLog* self, const LCHAR* token, int value); 79 80 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenUint16_t(SR_EventLog* self, const LCHAR* token, asr_uint16_t value); 81 82 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenSize_t(SR_EventLog* self, const LCHAR* token, size_t value); 83 84 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenBool(SR_EventLog* self, const LCHAR* token, ESR_BOOL value); 85 86 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_TokenFloat(SR_EventLog* self, const LCHAR* token, float value); 87 88 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLogEventSessionImpl(SR_EventLog* self); 89 90 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_Event(SR_EventLog* self, const LCHAR* eventName); 91 92 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioOpen(SR_EventLog* self, const LCHAR* audio_type, size_t sample_rate, size_t sample_size); 93 94 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioClose(SR_EventLog* self); 95 96 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioWrite(SR_EventLog* self, void* buffer, size_t num_bytes); 97 98 SREC_EVENTLOG_API ESR_ReturnCode SR_EventLog_AudioGetFilename(SR_EventLog* self, LCHAR* waveformFilename, size_t* len); 99 100 #endif /* __SR_EventLogIMPL_H */ 101