frontend: fix pulseaudio, detect it in configure script
authornotaz <notasas@gmail.com>
Sun, 23 Dec 2012 00:21:53 +0000 (02:21 +0200)
committernotaz <notasas@gmail.com>
Sun, 23 Dec 2012 01:55:06 +0000 (03:55 +0200)
configure
plugins/dfsound/pulseaudio.c

index f55e9b6..eb859bf 100755 (executable)
--- a/configure
+++ b/configure
@@ -36,7 +36,7 @@ platform_list="generic pandora maemo caanoo libretro"
 platform="generic"
 builtin_gpu_list="peops unai neon"
 builtin_gpu=""
 platform="generic"
 builtin_gpu_list="peops unai neon"
 builtin_gpu=""
-sound_driver_list="oss alsa sdl pulseaudio libretro"
+sound_driver_list="oss alsa pulseaudio sdl libretro"
 sound_drivers=""
 plugins="plugins/spunull/spunull.so \
 plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
 sound_drivers=""
 plugins="plugins/spunull/spunull.so \
 plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
@@ -308,6 +308,15 @@ EOF
   compile_binary "$@"
 }
 
   compile_binary "$@"
 }
 
+check_pulseaudio()
+{
+  cat > $TMPC <<EOF
+  #include <pulse/pulseaudio.h>
+  void main() { pa_threaded_mainloop_new(); }
+EOF
+  compile_binary "$@"
+}
+
 check_sdl()
 {
   cat > $TMPC <<EOF
 check_sdl()
 {
   cat > $TMPC <<EOF
@@ -330,6 +339,10 @@ if [ "x$sound_drivers" = "x" ]; then
     sound_drivers="$sound_drivers alsa"
     MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
   fi
     sound_drivers="$sound_drivers alsa"
     MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
   fi
+  if check_pulseaudio -lpulse; then
+    sound_drivers="$sound_drivers pulseaudio"
+    MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
+  fi
   if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then
     sound_drivers="$sound_drivers sdl"
     need_sdl="yes"
   if [ "$need_sdl" = "yes" ] || check_sdl `sdl-config --cflags --libs`; then
     sound_drivers="$sound_drivers sdl"
     need_sdl="yes"
@@ -342,6 +355,10 @@ else
     MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
     check_alsa || fail "please install libasound2-dev"
   fi
     MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
     check_alsa || fail "please install libasound2-dev"
   fi
+  if echo $sound_drivers | grep -q "\<pulseaudio\>"; then
+    MAIN_LDLIBS="-lpulse $MAIN_LDLIBS"
+    check_pulseaudio || fail "pulseaudio support is missing"
+  fi
 fi
 
 if [ "$need_sdl" = "yes" ]; then
 fi
 
 if [ "$need_sdl" = "yes" ]; then
index 057c2c4..8ffd58f 100644 (file)
@@ -17,12 +17,10 @@ comment              : Much of this was taken from simple.c, in the pulseaudio
  *                                                                         *
  ***************************************************************************/
 
  *                                                                         *
  ***************************************************************************/
 
-#include "stdafx.h"
+#include <stdio.h>
 
 
-#define _IN_OSS
-
-#include "externals.h"
 #include <pulse/pulseaudio.h>
 #include <pulse/pulseaudio.h>
+#include "out.h"
 
 ////////////////////////////////////////////////////////////////////////
 // pulseaudio structs
 
 ////////////////////////////////////////////////////////////////////////
 // pulseaudio structs
@@ -134,7 +132,7 @@ static void stream_request_cb (pa_stream *stream, size_t length, void *userdata)
 // SETUP SOUND
 ////////////////////////////////////////////////////////////////////////
 
 // SETUP SOUND
 ////////////////////////////////////////////////////////////////////////
 
-static void pulse_init(void)
+static int pulse_init(void)
 {
      int error_number;
 
 {
      int error_number;
 
@@ -227,7 +225,7 @@ static void pulse_init(void)
      //pa_stream_flags_t flags = (pa_stream_flags_t) (PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_EARLY_REQUESTS);
      if (pa_stream_connect_playback (device.stream, NULL, &buffer_attributes, flags, NULL, NULL) < 0)
      {
      //pa_stream_flags_t flags = (pa_stream_flags_t) (PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_EARLY_REQUESTS);
      if (pa_stream_connect_playback (device.stream, NULL, &buffer_attributes, flags, NULL, NULL) < 0)
      {
-         pa_context_errno (device.context);
+         error_number = pa_context_errno (device.context);
          fprintf (stderr, "Could not connect for playback: %s\n", pa_strerror (error_number));
          return -1;
      }
          fprintf (stderr, "Could not connect for playback: %s\n", pa_strerror (error_number));
          return -1;
      }
@@ -296,9 +294,6 @@ static void pulse_finish(void)
 static int pulse_busy(void)
 {
      int free_space;
 static int pulse_busy(void)
 {
      int free_space;
-     int error_code;
-     long latency;
-     int playing = 0;
 
      if ((device.mainloop == NULL) || (device.api == NULL) || ( device.context == NULL) || (device.stream == NULL))
          return 1;
 
      if ((device.mainloop == NULL) || (device.api == NULL) || ( device.context == NULL) || (device.stream == NULL))
          return 1;
@@ -329,9 +324,6 @@ static int pulse_busy(void)
 
 static void pulse_feed(void *pSound, int lBytes)
 {
 
 static void pulse_feed(void *pSound, int lBytes)
 {
-     int error_code;
-     int size;
-
      if (device.mainloop != NULL)
      {
          pa_threaded_mainloop_lock (device.mainloop);
      if (device.mainloop != NULL)
      {
          pa_threaded_mainloop_lock (device.mainloop);