1 /*---------------------------------------------------------------------------* 2 * EventLog.c * 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 #include "SR_EventLog.h" 21 #include "SR_EventLogImpl.h" 22 #include "pmemory.h" 23 #include "plog.h" 24 25 26 ESR_ReturnCode SR_EventLogDestroy(SR_EventLog* self) 27 { 28 if (self == NULL) 29 { 30 PLogError(L("ESR_INVALID_ARGUMENT")); 31 return ESR_INVALID_ARGUMENT; 32 } 33 return self->destroy(self); 34 } 35 36 ESR_ReturnCode SR_EventLogToken(SR_EventLog* self, const LCHAR* token, const LCHAR *value) 37 { 38 if (self == NULL) 39 { 40 PLogError(L("ESR_INVALID_ARGUMENT")); 41 return ESR_INVALID_ARGUMENT; 42 } 43 return self->token(self, token, value); 44 } 45 46 ESR_ReturnCode SR_EventLogTokenInt(SR_EventLog* self, const LCHAR* token, int value) 47 { 48 if (self == NULL) 49 { 50 PLogError(L("ESR_INVALID_ARGUMENT")); 51 return ESR_INVALID_ARGUMENT; 52 } 53 return self->tokenInt(self, token, value); 54 } 55 56 ESR_ReturnCode SR_EventLogTokenUint16_t(SR_EventLog* self, const LCHAR* token, asr_uint16_t value) 57 { 58 if (self == NULL) 59 { 60 PLogError(L("ESR_INVALID_ARGUMENT")); 61 return ESR_INVALID_ARGUMENT; 62 } 63 return self->tokenUint16_t(self, token, value); 64 } 65 66 ESR_ReturnCode SR_EventLogTokenSize_t(SR_EventLog* self, const LCHAR* token, size_t value) 67 { 68 if (self == NULL) 69 { 70 PLogError(L("ESR_INVALID_ARGUMENT")); 71 return ESR_INVALID_ARGUMENT; 72 } 73 return self->tokenSize_t(self, token, value); 74 } 75 76 ESR_ReturnCode SR_EventLogTokenBool(SR_EventLog* self, const LCHAR* token, ESR_BOOL value) 77 { 78 if (self == NULL) 79 { 80 PLogError(L("ESR_INVALID_ARGUMENT")); 81 return ESR_INVALID_ARGUMENT; 82 } 83 return self->tokenBool(self, token, value); 84 } 85 86 ESR_ReturnCode SR_EventLogTokenFloat(SR_EventLog* self, const LCHAR* token, float value) 87 { 88 if (self == NULL) 89 { 90 PLogError(L("ESR_INVALID_ARGUMENT")); 91 return ESR_INVALID_ARGUMENT; 92 } 93 return self->tokenFloat(self, token, value); 94 } 95 96 ESR_ReturnCode SR_EventLogEventSession(SR_EventLog* self) 97 { 98 if (self == NULL) 99 { 100 PLogError(L("ESR_INVALID_ARGUMENT")); 101 return ESR_INVALID_ARGUMENT; 102 } 103 return self->eventSession(self); 104 } 105 106 ESR_ReturnCode SR_EventLogEvent(SR_EventLog* self, const LCHAR *eventName) 107 { 108 if (self == NULL) 109 { 110 PLogError(L("ESR_INVALID_ARGUMENT")); 111 return ESR_INVALID_ARGUMENT; 112 } 113 return self->event(self, eventName); 114 } 115 116 ESR_ReturnCode SR_EventLogAudioOpen(SR_EventLog* self, const LCHAR* audio_type, size_t sample_rate, size_t sample_size) 117 { 118 if (self == NULL) 119 { 120 PLogError(L("ESR_INVALID_ARGUMENT")); 121 return ESR_INVALID_ARGUMENT; 122 } 123 return self->audioOpen(self, audio_type, sample_rate, sample_size); 124 } 125 126 ESR_ReturnCode SR_EventLogAudioClose(SR_EventLog* self) 127 { 128 if (self == NULL) 129 { 130 PLogError(L("ESR_INVALID_ARGUMENT")); 131 return ESR_INVALID_ARGUMENT; 132 } 133 return self->audioClose(self); 134 } 135 136 ESR_ReturnCode SR_EventLogAudioWrite(SR_EventLog* self, void* buffer, size_t num_bytes) 137 { 138 if (self == NULL) 139 { 140 PLogError(L("ESR_INVALID_ARGUMENT")); 141 return ESR_INVALID_ARGUMENT; 142 } 143 return self->audioWrite(self, buffer, num_bytes); 144 } 145 146 ESR_ReturnCode SR_EventLogAudioGetFilename(SR_EventLog* self, LCHAR* waveformFilename, size_t* len) 147 { 148 if (self == NULL) 149 { 150 PLogError(L("ESR_INVALID_ARGUMENT")); 151 return ESR_INVALID_ARGUMENT; 152 } 153 return self->audioGetFilename(self, waveformFilename, len); 154 } 155