2 * Copyright (C) 2015 "IoT.bzh"
3 * Author "Fulup Ar Foll"
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "audio-api.h"
20 #include "audio-alsa.h"
23 /* ------ LOCAL HELPER FUNCTIONS --------- */
25 /* private client context creation ; default values */
26 STATIC audioCtxHandleT* initAudioCtx () {
30 ctx = malloc (sizeof(audioCtxHandleT));
38 /* called when client session dies [e.g. client quits for more than 15mns] */
39 STATIC json_object* freeAudio (AFB_clientCtx *client) {
41 //releaseAudio (client->plugin->handle, client->ctx);
44 return jsonNewMessage (AFB_SUCCESS, "Released radio and client context");
48 /* ------ PUBLIC PLUGIN FUNCTIONS --------- */
50 STATIC json_object* init (AFB_request *request) { /* AFB_SESSION_CREATE */
55 /* create a private client context */
57 request->client->ctx = (audioCtxHandleT*)ctx;
59 _alsa_init("default", ctx);
61 jresp = json_object_new_object();
62 json_object_object_add (jresp, "token", json_object_new_string (request->client->token));
66 STATIC AFB_restapi pluginApis[]= {
67 {"init" , AFB_SESSION_CREATE, (AFB_apiCB)init , "Audio API - init"},
68 // {"error" , AFB_SESSION_CHECK, (AFB_apiCB)wrongApi , "Ping Application Framework"},
73 PUBLIC AFB_plugin *audioRegister () {
74 AFB_plugin *plugin = malloc (sizeof(AFB_plugin));
75 plugin->type = AFB_PLUGIN_JSON;
76 plugin->info = "Application Framework Binder - Audio plugin";
77 plugin->prefix = "audio";
78 plugin->apis = pluginApis;
80 plugin->freeCtxCB = freeAudio;