notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(Vita) Disable debug
[pcsx_rearmed.git]
/
plugins
/
dfsound
/
pulseaudio.c
diff --git
a/plugins/dfsound/pulseaudio.c
b/plugins/dfsound/pulseaudio.c
index
1dadd88
..
8ffd58f
100644
(file)
--- a/
plugins/dfsound/pulseaudio.c
+++ b/
plugins/dfsound/pulseaudio.c
@@
-17,14
+17,10
@@
comment : Much of this was taken from simple.c, in the pulseaudio
* *
***************************************************************************/
* *
***************************************************************************/
-#include
"stdafx.h"
+#include
<stdio.h>
-#ifdef USEPULSEAUDIO
-
-#define _IN_OSS
-
-#include "externals.h"
#include <pulse/pulseaudio.h>
#include <pulse/pulseaudio.h>
+#include "out.h"
////////////////////////////////////////////////////////////////////////
// pulseaudio structs
////////////////////////////////////////////////////////////////////////
// pulseaudio structs
@@
-136,7
+132,7
@@
static void stream_request_cb (pa_stream *stream, size_t length, void *userdata)
// SETUP SOUND
////////////////////////////////////////////////////////////////////////
// SETUP SOUND
////////////////////////////////////////////////////////////////////////
-
void SetupSound
(void)
+
static int pulse_init
(void)
{
int error_number;
{
int error_number;
@@
-145,7
+141,7
@@
void SetupSound (void)
if (device.mainloop == NULL)
{
fprintf (stderr, "Could not acquire PulseAudio main loop\n");
if (device.mainloop == NULL)
{
fprintf (stderr, "Could not acquire PulseAudio main loop\n");
- return;
+ return
-1
;
}
// Acquire context ////////////////////////////////////////////////////////
}
// Acquire context ////////////////////////////////////////////////////////
@@
-156,7
+152,7
@@
void SetupSound (void)
if (device.context == NULL)
{
fprintf (stderr, "Could not acquire PulseAudio device context\n");
if (device.context == NULL)
{
fprintf (stderr, "Could not acquire PulseAudio device context\n");
- return;
+ return
-1
;
}
// Connect to PulseAudio server ///////////////////////////////////////////
}
// Connect to PulseAudio server ///////////////////////////////////////////
@@
-164,7
+160,7
@@
void SetupSound (void)
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Could not connect to PulseAudio server: %s\n", pa_strerror(error_number));
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Could not connect to PulseAudio server: %s\n", pa_strerror(error_number));
- return;
+ return
-1
;
}
// Run mainloop until sever context is ready //////////////////////////////
}
// Run mainloop until sever context is ready //////////////////////////////
@@
-172,7
+168,7
@@
void SetupSound (void)
if (pa_threaded_mainloop_start (device.mainloop) < 0)
{
fprintf (stderr, "Could not start mainloop\n");
if (pa_threaded_mainloop_start (device.mainloop) < 0)
{
fprintf (stderr, "Could not start mainloop\n");
- return;
+ return
-1
;
}
pa_context_state_t context_state;
}
pa_context_state_t context_state;
@@
-184,7
+180,7
@@
void SetupSound (void)
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Context state is not good: %s\n", pa_strerror (error_number));
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Context state is not good: %s\n", pa_strerror (error_number));
- return;
+ return
-1
;
}
else if (context_state == PA_CONTEXT_READY)
break;
}
else if (context_state == PA_CONTEXT_READY)
break;
@@
-216,7
+212,7
@@
void SetupSound (void)
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Could not acquire new PulseAudio stream: %s\n", pa_strerror (error_number));
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Could not acquire new PulseAudio stream: %s\n", pa_strerror (error_number));
- return;
+ return
-1
;
}
// Set callbacks for server events ////////////////////////////////////////
}
// Set callbacks for server events ////////////////////////////////////////
@@
-229,9
+225,9
@@
void SetupSound (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));
fprintf (stderr, "Could not connect for playback: %s\n", pa_strerror (error_number));
- return;
+ return
-1
;
}
// Run mainloop until stream is ready /////////////////////////////////////
}
// Run mainloop until stream is ready /////////////////////////////////////
@@
-248,7
+244,7
@@
void SetupSound (void)
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Stream state is not good: %s\n", pa_strerror (error_number));
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Stream state is not good: %s\n", pa_strerror (error_number));
- return;
+ return
-1
;
}
else
fprintf (stderr, "PulseAudio stream state is %d\n", stream_state);
}
else
fprintf (stderr, "PulseAudio stream state is %d\n", stream_state);
@@
-258,13
+254,13
@@
void SetupSound (void)
pa_threaded_mainloop_unlock (device.mainloop);
fprintf (stderr, "PulseAudio should be connected\n");
pa_threaded_mainloop_unlock (device.mainloop);
fprintf (stderr, "PulseAudio should be connected\n");
- return;
+ return
0
;
}
////////////////////////////////////////////////////////////////////////
// REMOVE SOUND
////////////////////////////////////////////////////////////////////////
}
////////////////////////////////////////////////////////////////////////
// REMOVE SOUND
////////////////////////////////////////////////////////////////////////
-
void RemoveSound
(void)
+
static void pulse_finish
(void)
{
if (device.mainloop != NULL)
pa_threaded_mainloop_stop (device.mainloop);
{
if (device.mainloop != NULL)
pa_threaded_mainloop_stop (device.mainloop);
@@
-295,12
+291,9
@@
void RemoveSound (void)
// GET BYTES BUFFERED
////////////////////////////////////////////////////////////////////////
// GET BYTES BUFFERED
////////////////////////////////////////////////////////////////////////
-
unsigned long SoundGetBytesBuffered
(void)
+
static int pulse_busy
(void)
{
int free_space;
{
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,11
+322,8
@@
unsigned long SoundGetBytesBuffered (void)
// FEED SOUND DATA
////////////////////////////////////////////////////////////////////////
// FEED SOUND DATA
////////////////////////////////////////////////////////////////////////
-
void SoundFeedStreamData (unsigned char *pSound, long
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);
@@
-348,4
+338,12
@@
void SoundFeedStreamData (unsigned char *pSound, long lBytes)
}
}
}
}
}
}
-#endif
+
+void out_register_pulse(struct out_driver *drv)
+{
+ drv->name = "pulseaudio";
+ drv->init = pulse_init;
+ drv->finish = pulse_finish;
+ drv->busy = pulse_busy;
+ drv->feed = pulse_feed;
+}