uint32_t handle;
int mode;
- int policy;
int volume_type;
int gain_type;
int rate;
int source_type;
} mm_sound_handle_t;
-#define MM_SOUND_HANDLE_MAX 32
static struct {
uint32_t handle_count; /* use amotic operations */
GList* handles;
} \
} while(0);
-#define CHECK_VOLUME_TYPE_RANGE(x) \
- do { \
- if(x < VOLUME_TYPE_SYSTEM || x >= VOLUME_TYPE_MAX) { \
- debug_msg("invalid volume type(%d)", x); \
- return MM_ERROR_INVALID_ARGUMENT; \
- } \
- } while(0);
-
#define ATOMIC_INC(l, x) \
do { \
pthread_mutex_lock(l); \
} while(0);
-// should be call after pa_ext function.
-#define WAIT_PULSEAUDIO_OPERATION(x, y) \
- do { \
- while (pa_operation_get_state(y) == PA_OPERATION_RUNNING) { \
- debug_msg("waiting.................."); \
- pa_threaded_mainloop_wait(x.mainloop); \
- debug_msg("waiting DONE"); \
- } \
- } while(0);
-
-#define PA_SIMPLE_FADE_INTERVAL_USEC 20000
-
#define PA_SIMPLE_SAMPLES_PER_PERIOD_DEFAULT 1536 /* frames */
#define PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE 4
#define PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT 6
#define PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC 25
#define PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC 50
#define PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC 75
-#define PA_SIMPLE_PERIOD_TIME_FOR_VERY_HIGH_LATENCY_MSEC 150
#define PA_SIMPLE_PERIOD_TIME_FOR_VOIP_LATENCY_MSEC 20
-#define IS_INPUT_HANDLE(x) \
- if( x == HANDLE_MODE_INPUT || x == HANDLE_MODE_INPUT_HIGH_LATENCY || \
- x == HANDLE_MODE_INPUT_LOW_LATENCY || x == HANDLE_MODE_INPUT_AP_CALL )
-
__attribute__ ((constructor)) void __mm_sound_pa_init(void)
{
memset(&mm_sound_handle_mgr, 0, sizeof(mm_sound_handle_mgr));
}
EXPORT_API
-int mm_sound_pa_open(MMSoundHandleMode mode, mm_sound_handle_route_info *route_info, MMSoundHandlePriority priority, int volume_config, pa_sample_spec* ss, pa_channel_map* channel_map, int* size, char *stream_type, int stream_index)
+int mm_sound_pa_open(MMSoundHandleMode mode, int volume_config, pa_sample_spec* ss, pa_channel_map* channel_map, int* size, char *stream_type, int stream_index)
{
pa_simple *s = NULL;
pa_channel_map maps;
int periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT;
int handle_mode = mode;
- int handle_inout = HANDLE_DIRECTION_NONE;
int sample_size = 0;
pa_proplist *proplist = NULL;
mm_sound_handle_t* handle = NULL;
- MMSoundHandleRoutePolicy policy = HANDLE_ROUTE_POLICY_DEFAULT;
-
- if(route_info) {
- policy = route_info->policy;
- }
if (ss->channels < MM_SOUND_CHANNEL_MIN || ss->channels > MM_SOUND_CHANNEL_MAX)
return MM_ERROR_INVALID_ARGUMENT;
handle = (mm_sound_handle_t*)malloc(sizeof(mm_sound_handle_t));
memset(handle, 0, sizeof(mm_sound_handle_t));
handle->mode = mode;
- handle->policy = policy;
handle->volume_type = prop_vol_type;
handle->gain_type = prop_gain_type;
handle->rate = ss->rate;
goto fail;
}
- debug_msg("created handle[%d]. mode(%d), policy(%d), volumetype(%d), gain(%d), rate(%d), channels(%d), format(%d), stream_idx(%d), s(%x), source_type(%d) handle_inout(%d)",
- handle->handle, handle->mode, handle->policy, handle->volume_type, handle->gain_type,
- handle->rate, handle->channels, ss->format, handle->stream_idx, handle->s, handle->source_type, handle_inout);
+ debug_msg("created handle[%d]. mode(%d), volumetype(%d), gain(%d), rate(%d), channels(%d), format(%d), stream_idx(%d), s(%x), source_type(%d)",
+ handle->handle, handle->mode, handle->volume_type, handle->gain_type,
+ handle->rate, handle->channels, ss->format, handle->stream_idx, handle->s, handle->source_type);
+
+ if (proplist)
+ pa_proplist_free(proplist);
return handle->handle;
}
EXPORT_API
-int mm_sound_pa_read(const int handle, void* buf, const int size)
-{
- mm_sound_handle_t* phandle = NULL;
- int err = MM_ERROR_NONE;
-
-#ifdef __STREAM_DEBUG__
- debug_msg("handle(%d), buf(%p), size(%d)", handle, buf, size);
-#endif
- if (buf == NULL)
- return MM_ERROR_INVALID_ARGUMENT;
-
- if (size < 0)
- return MM_ERROR_INVALID_ARGUMENT;
- else if (size == 0)
- return size;
-
- CHECK_HANDLE_RANGE(handle);
- GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc);
- if(phandle == NULL) {
- debug_msg("phandle is null");
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- if (0 > pa_simple_read(phandle->s, buf, size, &err)) {
- debug_error("pa_simple_read() failed with %s", pa_strerror(err));
- return MM_ERROR_SOUND_INTERNAL;
- }
-
- return size;
-}
-
-EXPORT_API
int mm_sound_pa_write(const int handle, void* buf, const int size)
{
mm_sound_handle_t* phandle = NULL;
return err;
}
-EXPORT_API
-int mm_sound_pa_flush(const int handle)
-{
- mm_sound_handle_t* phandle = NULL;
- int err = MM_ERROR_NONE;
-
- CHECK_HANDLE_RANGE(handle);
- GET_HANDLE_DATA(phandle, mm_sound_handle_mgr.handles, &handle, __mm_sound_handle_comparefunc);
- if(phandle == NULL)
- return MM_ERROR_SOUND_INTERNAL;
-
- if (0 > pa_simple_flush(phandle->s, &err)) {
- debug_error("pa_simple_flush() failed with %s\n", pa_strerror(err));
- err = MM_ERROR_SOUND_INTERNAL;
- }
-
- return err;
-}
-
-typedef struct _get_volume_max_userdata_t
-{
- pa_threaded_mainloop* mainloop;
- int value;
-} get_volume_max_userdata_t;