Blame channels/rdpsnd/client/opensles/opensl_io.h

Packit Service fa4841
/*
Packit Service fa4841
opensl_io.c:
Packit Service fa4841
Android OpenSL input/output module header
Packit Service fa4841
Copyright (c) 2012, Victor Lazzarini
Packit Service fa4841
All rights reserved.
Packit Service fa4841
Packit Service fa4841
Redistribution and use in source and binary forms, with or without
Packit Service fa4841
modification, are permitted provided that the following conditions are met:
Packit Service bb5c11
	* Redistributions of source code must retain the above copyright
Packit Service bb5c11
	  notice, this list of conditions and the following disclaimer.
Packit Service bb5c11
	* Redistributions in binary form must reproduce the above copyright
Packit Service bb5c11
	  notice, this list of conditions and the following disclaimer in the
Packit Service bb5c11
	  documentation and/or other materials provided with the distribution.
Packit Service bb5c11
	* Neither the name of the <organization> nor the
Packit Service bb5c11
	  names of its contributors may be used to endorse or promote products
Packit Service bb5c11
	  derived from this software without specific prior written permission.
Packit Service fa4841
Packit Service fa4841
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Packit Service fa4841
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Packit Service fa4841
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit Service fa4841
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
Packit Service fa4841
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Packit Service fa4841
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Packit Service fa4841
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Packit Service fa4841
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service fa4841
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit Service fa4841
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service fa4841
*/
Packit Service fa4841
Packit Service fa4841
#ifndef FREERDP_CHANNEL_RDPSND_CLIENT_OPENSL_IO_H
Packit Service fa4841
#define FREERDP_CHANNEL_RDPSND_CLIENT_OPENSL_IO_H
Packit Service fa4841
Packit Service fa4841
#include <SLES/OpenSLES.h>
Packit Service fa4841
#include <SLES/OpenSLES_Android.h>
Packit Service fa4841
#include <stdlib.h>
Packit Service fa4841
#include <winpr/synch.h>
Packit Service fa4841
Packit Service fa4841
#include <freerdp/api.h>
Packit Service fa4841
Packit Service fa4841
#ifdef __cplusplus
Packit Service bb5c11
extern "C" {
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service bb5c11
typedef struct opensl_stream
Packit Service bb5c11
{
Packit Service bb5c11
	// engine interfaces
Packit Service bb5c11
	SLObjectItf engineObject;
Packit Service bb5c11
	SLEngineItf engineEngine;
Packit Service fa4841
Packit Service bb5c11
	// output mix interfaces
Packit Service bb5c11
	SLObjectItf outputMixObject;
Packit Service fa4841
Packit Service bb5c11
	// buffer queue player interfaces
Packit Service bb5c11
	SLObjectItf bqPlayerObject;
Packit Service bb5c11
	SLPlayItf bqPlayerPlay;
Packit Service bb5c11
	SLVolumeItf bqPlayerVolume;
Packit Service bb5c11
	SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;
Packit Service bb5c11
	SLEffectSendItf bqPlayerEffectSend;
Packit Service fa4841
Packit Service bb5c11
	unsigned int outchannels;
Packit Service bb5c11
	unsigned int sr;
Packit Service fa4841
Packit Service bb5c11
	unsigned int queuesize;
Packit Service bb5c11
	wQueue* queue;
Packit Service bb5c11
} OPENSL_STREAM;
Packit Service fa4841
Packit Service bb5c11
/*
Packit Service bb5c11
Open the audio device with a given sampling rate (sr), output channels and IO buffer size
Packit Service bb5c11
in frames. Returns a handle to the OpenSL stream
Packit Service bb5c11
*/
Packit Service bb5c11
FREERDP_LOCAL OPENSL_STREAM* android_OpenAudioDevice(int sr, int outchannels,
Packit Service bb5c11
        int bufferframes);
Packit Service bb5c11
/*
Packit Service bb5c11
Close the audio device
Packit Service bb5c11
*/
Packit Service bb5c11
FREERDP_LOCAL void android_CloseAudioDevice(OPENSL_STREAM* p);
Packit Service bb5c11
/*
Packit Service bb5c11
Write a buffer to the OpenSL stream *p, of size samples. Returns the number of samples written.
Packit Service bb5c11
*/
Packit Service bb5c11
FREERDP_LOCAL int android_AudioOut(OPENSL_STREAM* p, const short* buffer,
Packit Service bb5c11
                                   int size);
Packit Service bb5c11
/*
Packit Service bb5c11
 * Set the volume input level.
Packit Service bb5c11
 */
Packit Service bb5c11
FREERDP_LOCAL void android_SetInputVolume(OPENSL_STREAM* p, int level);
Packit Service bb5c11
/*
Packit Service bb5c11
 * Get the current output mute setting.
Packit Service bb5c11
 */
Packit Service bb5c11
FREERDP_LOCAL int android_GetOutputMute(OPENSL_STREAM* p);
Packit Service bb5c11
/*
Packit Service bb5c11
 * Change the current output mute setting.
Packit Service bb5c11
 */
Packit Service bb5c11
FREERDP_LOCAL BOOL android_SetOutputMute(OPENSL_STREAM* p, BOOL mute);
Packit Service bb5c11
/*
Packit Service bb5c11
 * Get the current output volume level.
Packit Service bb5c11
 */
Packit Service bb5c11
FREERDP_LOCAL int android_GetOutputVolume(OPENSL_STREAM* p);
Packit Service bb5c11
/*
Packit Service bb5c11
 * Get the maximum output volume level.
Packit Service bb5c11
 */
Packit Service bb5c11
FREERDP_LOCAL int android_GetOutputVolumeMax(OPENSL_STREAM* p);
Packit Service fa4841
Packit Service bb5c11
/*
Packit Service bb5c11
 * Set the volume output level.
Packit Service bb5c11
 */
Packit Service bb5c11
FREERDP_LOCAL BOOL android_SetOutputVolume(OPENSL_STREAM* p, int level);
Packit Service fa4841
#ifdef __cplusplus
Packit Service fa4841
};
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#endif /* FREERDP_CHANNEL_RDPSND_CLIENT_OPENSL_IO_H */