Christopher N. Hesse | 41c9f3d | 2017-02-02 20:48:56 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 Christopher N. Hesse <raymanfx@gmail.com> |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "audio_hw_voice" |
| 18 | #define LOG_NDEBUG 0 |
| 19 | /*#define VERY_VERY_VERBOSE_LOGGING*/ |
| 20 | #ifdef VERY_VERY_VERBOSE_LOGGING |
| 21 | #define ALOGVV ALOGV |
| 22 | #else |
| 23 | #define ALOGVV(a...) do { } while(0) |
| 24 | #endif |
| 25 | |
| 26 | #include <stdlib.h> |
| 27 | #include <pthread.h> |
| 28 | |
| 29 | #include "audio_hw.h" |
| 30 | #include "voice.h" |
| 31 | |
| 32 | struct voice_session *voice_session_init(void) |
| 33 | { |
| 34 | struct voice_session *session; |
| 35 | int ret; |
| 36 | |
| 37 | session = calloc(1, sizeof(struct voice_session)); |
| 38 | if (session == NULL) { |
| 39 | return NULL; |
| 40 | } |
| 41 | |
| 42 | /* Do this as the last step so we do not have to close it on error */ |
| 43 | ret = ril_open(&session->ril); |
| 44 | if (ret != 0) { |
| 45 | free(session); |
| 46 | return NULL; |
| 47 | } |
| 48 | |
| 49 | return session; |
| 50 | } |
| 51 | |
| 52 | void voice_session_deinit(struct voice_session *session) |
| 53 | { |
| 54 | ril_close(&session->ril); |
| 55 | free(session); |
| 56 | } |