- pa_simple *s = NULL;
- pa_channel_map maps;
- pa_buffer_attr attr;
-
- int prop_vol_type, prop_gain_type = VOLUME_GAIN_DEFAULT;
-
- int err = MM_ERROR_SOUND_INTERNAL;
- int period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC;
- int samples_per_period = PA_SIMPLE_SAMPLES_PER_PERIOD_DEFAULT;
- 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;
-
- proplist = pa_proplist_new();
-
- if(channel_map == NULL) {
- pa_channel_map_init_auto(&maps, ss->channels, PA_CHANNEL_MAP_ALSA);
- channel_map = &maps;
- }
-
- switch(ss->format) {
- case PA_SAMPLE_U8:
- sample_size = 1 * ss->channels;
- break;
- case PA_SAMPLE_S16LE:
- sample_size = 2 * ss->channels;
- break;
- default :
- sample_size = 0;
- debug_error("Invalid sample size (%d)", sample_size);
- break;
- }
-
- /* Set volume type of stream */
- if(volume_config > 0) {
- debug_log("setting gain type");
- prop_vol_type = 0; /* not used, set it system(0) temporarily */
-
- /* Set gain type of stream */
- prop_gain_type = (volume_config >> 8) & 0x000000FF;
-
- pa_proplist_setf(proplist, PA_PROP_MEDIA_TIZEN_GAIN_TYPE, "%d", prop_gain_type);
- }
-
- if (stream_index != -1) {
- char stream_index_s[11];
- debug_msg("Set stream index [%d]", stream_index);
-
- snprintf(stream_index_s, sizeof(stream_index_s)-1, "%d", stream_index);
- debug_msg("stream_index[%d] converted to string[%s]", stream_index, stream_index_s);
- pa_proplist_sets(proplist, PA_PROP_MEDIA_PARENT_ID, stream_index_s);
- }
- /* Set stream type */
- pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, stream_type);
-
- memset(&attr, '\0', sizeof(attr));
-
- switch (handle_mode) {
- case HANDLE_MODE_INPUT:
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT;
- attr.prebuf = 0;
- attr.minreq = -1;
- attr.tlength = -1;
- attr.maxlength = -1;
- attr.fragsize = samples_per_period * pa_sample_size(ss);
-
- s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "CAPTURE", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_INPUT_LOW_LATENCY:
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_ULOW_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE;
- attr.prebuf = 0;
- attr.minreq = -1;
- attr.tlength = -1;
- attr.maxlength = -1;
- attr.fragsize = samples_per_period * pa_sample_size(ss);
-
- s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "LOW LATENCY CAPTURE", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_INPUT_HIGH_LATENCY:
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_CAPTURE;
- attr.prebuf = 0;
- attr.minreq = -1;
- attr.tlength = -1;
- attr.maxlength = -1;
- attr.fragsize = samples_per_period * pa_sample_size(ss);
-
- s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "HIGH LATENCY CAPTURE", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_OUTPUT:
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT;
- attr.prebuf = -1;
- attr.minreq = -1;
- attr.tlength = (ss->rate / 10) * pa_sample_size(ss) * ss->channels;
- attr.maxlength = -1;
- attr.fragsize = 0;
-
- s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "PLAYBACK", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_OUTPUT_LOW_LATENCY:
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE;
- attr.prebuf = (ss->rate / 100) * pa_sample_size(ss) * ss->channels;
- attr.minreq = -1;
- attr.tlength = (ss->rate / 10) * pa_sample_size(ss) * ss->channels;
- attr.maxlength = -1;
- attr.fragsize = 0;
- debug_msg("rate(%d), samplesize(%d), ch(%d) format(%d)", ss->rate, pa_sample_size(ss), ss->channels, ss->format);
-
- debug_msg("prebuf(%d), minreq(%d), tlength(%d), maxlength(%d), fragsize(%d)", attr.prebuf, attr.minreq, attr.tlength, attr.maxlength, attr.fragsize);
-
- s = pa_simple_new_proplist(NULL,"MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "LOW LATENCY PLAYBACK", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_OUTPUT_CLOCK:
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_PLAYBACK;
- attr.prebuf = -1;
- attr.minreq = -1;
- attr.tlength = (uint32_t)-1;
- attr.maxlength = -1;
- attr.fragsize = 0;
-
- s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "HIGH LATENCY PLAYBACK", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_OUTPUT_VIDEO: /* low latency playback */
- period_time = PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
- samples_per_period = (ss->rate * period_time) / 1000;
- periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_VIDEO;
- attr.prebuf = 4*(samples_per_period * pa_sample_size(ss));
- attr.minreq = samples_per_period * pa_sample_size(ss);
- attr.tlength = periods_per_buffer * samples_per_period * pa_sample_size(ss);
- attr.maxlength = -1;
- attr.fragsize = 0;
-
- s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "LOW LATENCY PLAYBACK", ss, channel_map, &attr, proplist, &err);
- break;
-
- case HANDLE_MODE_OUTPUT_AP_CALL:
+ pa_simple *s = NULL;
+ pa_channel_map maps;
+ pa_buffer_attr attr;
+
+ int prop_vol_type = 0;
+ int prop_gain_type = VOLUME_GAIN_DEFAULT;
+
+ int err = MM_ERROR_SOUND_INTERNAL;
+ int period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC;
+ int samples_per_period = PA_SIMPLE_SAMPLES_PER_PERIOD_DEFAULT;
+ int periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT;
+
+ int handle_mode = mode;
+ int sample_size = 0;
+ pa_proplist *proplist = NULL;
+
+ mm_sound_handle_t *handle = NULL;
+
+ if (ss->channels < MM_SOUND_CHANNEL_MIN || ss->channels > MM_SOUND_CHANNEL_MAX)
+ return MM_ERROR_INVALID_ARGUMENT;
+
+ proplist = pa_proplist_new();
+
+ if (channel_map == NULL) {
+ pa_channel_map_init_auto(&maps, ss->channels, PA_CHANNEL_MAP_ALSA);
+ channel_map = &maps;
+ }
+
+ switch (ss->format) {
+ case PA_SAMPLE_U8:
+ sample_size = 1 * ss->channels;
+ break;
+ case PA_SAMPLE_S16LE:
+ sample_size = 2 * ss->channels;
+ break;
+ default:
+ sample_size = 0;
+ debug_error("Invalid sample size (%d)", sample_size);
+ break;
+ }
+
+ /* Set volume type of stream */
+ if (volume_config > 0) {
+ debug_log("setting gain type");
+ prop_vol_type = 0; /* not used, set it system(0) temporarily */
+
+ /* Set gain type of stream */
+ prop_gain_type = (volume_config >> 8) & 0x000000FF;
+
+ pa_proplist_setf(proplist, PA_PROP_MEDIA_TIZEN_GAIN_TYPE, "%d", prop_gain_type);
+ }
+
+ if (stream_index != -1) {
+ char stream_index_s[11];
+ debug_msg("Set stream index [%d]", stream_index);
+
+ snprintf(stream_index_s, sizeof(stream_index_s) - 1, "%d", stream_index);
+ debug_msg("stream_index[%d] converted to string[%s]", stream_index, stream_index_s);
+ pa_proplist_sets(proplist, PA_PROP_MEDIA_PARENT_ID, stream_index_s);
+ }
+ /* Set stream type */
+ pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, stream_type);
+
+ memset(&attr, '\0', sizeof(attr));
+
+ switch (handle_mode) {
+ case HANDLE_MODE_INPUT:
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT;
+ attr.prebuf = 0;
+ attr.minreq = -1;
+ attr.tlength = -1;
+ attr.maxlength = -1;
+ attr.fragsize = samples_per_period * pa_sample_size(ss);
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "CAPTURE", ss, channel_map, &attr,
+ proplist, &err);
+ break;
+
+ case HANDLE_MODE_INPUT_LOW_LATENCY:
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_ULOW_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE;
+ attr.prebuf = 0;
+ attr.minreq = -1;
+ attr.tlength = -1;
+ attr.maxlength = -1;
+ attr.fragsize = samples_per_period * pa_sample_size(ss);
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "LOW LATENCY CAPTURE", ss, channel_map,
+ &attr, proplist, &err);
+ break;
+
+ case HANDLE_MODE_INPUT_HIGH_LATENCY:
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_CAPTURE;
+ attr.prebuf = 0;
+ attr.minreq = -1;
+ attr.tlength = -1;
+ attr.maxlength = -1;
+ attr.fragsize = samples_per_period * pa_sample_size(ss);
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_RECORD, NULL, "HIGH LATENCY CAPTURE", ss, channel_map,
+ &attr, proplist, &err);
+ break;
+
+ case HANDLE_MODE_OUTPUT:
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_MID_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_DEFAULT;
+ attr.prebuf = -1;
+ attr.minreq = -1;
+ attr.tlength = (ss->rate / 10) * pa_sample_size(ss) * ss->channels;
+ attr.maxlength = -1;
+ attr.fragsize = 0;
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "PLAYBACK", ss, channel_map, &attr,
+ proplist, &err);
+ break;
+
+ case HANDLE_MODE_OUTPUT_LOW_LATENCY:
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_FASTMODE;
+ attr.prebuf = (ss->rate / 100) * pa_sample_size(ss) * ss->channels;
+ attr.minreq = -1;
+ attr.tlength = (ss->rate / 10) * pa_sample_size(ss) * ss->channels;
+ attr.maxlength = -1;
+ attr.fragsize = 0;
+ debug_msg("rate(%d), samplesize(%d), ch(%d) format(%d)", ss->rate, pa_sample_size(ss), ss->channels, ss->format);
+
+ debug_msg("prebuf(%d), minreq(%d), tlength(%d), maxlength(%d), fragsize(%d)", attr.prebuf, attr.minreq, attr.tlength,
+ attr.maxlength, attr.fragsize);
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "LOW LATENCY PLAYBACK", ss,
+ channel_map, &attr, proplist, &err);
+ break;
+
+ case HANDLE_MODE_OUTPUT_CLOCK:
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_HIGH_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_PLAYBACK;
+ attr.prebuf = -1;
+ attr.minreq = -1;
+ attr.tlength = (uint32_t) - 1;
+ attr.maxlength = -1;
+ attr.fragsize = 0;
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "HIGH LATENCY PLAYBACK", ss,
+ channel_map, &attr, proplist, &err);
+ break;
+
+ case HANDLE_MODE_OUTPUT_VIDEO: /* low latency playback */
+ period_time = PA_SIMPLE_PERIOD_TIME_FOR_LOW_LATENCY_MSEC;
+ samples_per_period = (ss->rate * period_time) / 1000;
+ periods_per_buffer = PA_SIMPLE_PERIODS_PER_BUFFER_VIDEO;
+ attr.prebuf = 4 * (samples_per_period * pa_sample_size(ss));
+ attr.minreq = samples_per_period * pa_sample_size(ss);
+ attr.tlength = periods_per_buffer * samples_per_period * pa_sample_size(ss);
+ attr.maxlength = -1;
+ attr.fragsize = 0;
+
+ s = pa_simple_new_proplist(NULL, "MM_SOUND_PA_CLIENT", PA_STREAM_PLAYBACK, NULL, "LOW LATENCY PLAYBACK", ss,
+ channel_map, &attr, proplist, &err);
+ break;
+
+ case HANDLE_MODE_OUTPUT_AP_CALL: