-#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
-
- pthread_mutex_init(&(info->play_mutex), NULL);
- pthread_cond_init(&(info->play_cond), NULL);
-
-#ifdef _MMCAMCORDER_UPLOAD_SAMPLE
- /* read sample */
- memset (&(info->sfinfo), 0, sizeof(SF_INFO));
- info->infile = sf_open(info->filename, SFM_READ, &(info->sfinfo));
- if (!(info->infile)) {
- _mmcam_dbg_err("Failed to open sound file");
- goto SOUND_INIT_ERROR;
- }
-#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
-
- if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
- int errorcode;
- ASM_resource_t mm_resource = mm_resource = ASM_RESOURCE_CAMERA | ASM_RESOURCE_VIDEO_OVERLAY | ASM_RESOURCE_HW_ENCODER;
-
- /* set EXCLUSIVE session as PLAYING to pause other session */
- if (!ASM_set_sound_state(hcamcorder->asm_handle_ex, ASM_EVENT_EXCLUSIVE_MMCAMCORDER,
- ASM_STATE_PLAYING, mm_resource, &errorcode)) {
- _mmcam_dbg_err("Set state to playing failed 0x%x", errorcode);
- ret = MM_ERROR_POLICY_BLOCKED;
- goto SOUND_INIT_ERROR;
- }
-
- _mmcam_dbg_log("EXCLUSIVE session PLAYING done.");
- } else {
- _mmcam_dbg_log("do not register session to pause another playing session");
- }
-
- /**
- * Init Pulseaudio thread
- */
- /* create pulseaudio mainloop */
- info->pulse_mainloop = pa_threaded_mainloop_new();
- ret = pa_threaded_mainloop_start(info->pulse_mainloop);
-
- /* lock pulseaudio thread */
- pa_threaded_mainloop_lock(info->pulse_mainloop);
- /* get pulseaudio api */
- api = pa_threaded_mainloop_get_api(info->pulse_mainloop);
- /* create pulseaudio context */
- info->pulse_context = pa_context_new(api, NULL);
- /* set pulseaudio context callback */
- pa_context_set_state_callback(info->pulse_context, __pulseaudio_context_state_cb, info);
-
- if (pa_context_connect(info->pulse_context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) {
- _mmcam_dbg_err("pa_context_connect error");
- }
-
- /* wait READY state of pulse context */
- while (TRUE) {
- pa_context_state_t state = pa_context_get_state(info->pulse_context);
-
- _mmcam_dbg_log("pa context state is now %d", state);
-
- if (!PA_CONTEXT_IS_GOOD (state)) {
- _mmcam_dbg_log("connection failed");
- break;
- }
-
- if (state == PA_CONTEXT_READY) {
- _mmcam_dbg_log("pa context READY");
- break;
- }
-
- /* Wait until the context is ready */
- _mmcam_dbg_log("waiting..................");
- pa_threaded_mainloop_wait(info->pulse_mainloop);
- _mmcam_dbg_log("waiting DONE. check again...");
- }
-
- /* unlock pulseaudio thread */
- pa_threaded_mainloop_unlock(info->pulse_mainloop);