/*
This file is part of GNUnet.
- (C) 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file conversation/gnunet-helper-audio-playback.c
GNUNET_NETWORK_STRUCT_END
-/*Process an Opus header and setup the opus decoder based on it.
- It takes several pointers for header values which are needed
- elsewhere in the code.*/
+/**
+ * Process an Opus header and setup the opus decoder based on it.
+ * It takes several pointers for header values which are needed
+ * elsewhere in the code.
+ */
static OpusDecoder *
process_header (ogg_packet *op)
{
if (header.channel_mapping != 0)
{
- fprintf (stderr, "This implementation does not support non-mono streams\n");
+ fprintf (stderr,
+ "This implementation does not support non-mono streams\n");
return NULL;
}
dec = opus_decoder_create (SAMPLING_RATE, channels, &err);
if (OPUS_OK != err)
{
- fprintf (stderr, "Cannot create encoder: %s\n", opus_strerror (err));
+ fprintf (stderr,
+ "Cannot create encoder: %s\n",
+ opus_strerror (err));
return NULL;
}
- if (!dec)
+ if (! dec)
{
- fprintf (stderr, "Decoder initialization failed: %s\n", opus_strerror (err));
+ fprintf (stderr,
+ "Decoder initialization failed: %s\n",
+ opus_strerror (err));
return NULL;
}
#ifdef DEBUG_DUMP_DECODED_OGG
-static size_t fwrite_le32(opus_int32 i32, FILE *file)
+static size_t
+fwrite_le32(opus_int32 i32, FILE *file)
{
unsigned char buf[4];
buf[0]=(unsigned char)(i32&0xFF);
return fwrite(buf,4,1,file);
}
-static size_t fwrite_le16(int i16, FILE *file)
+
+static size_t
+fwrite_le16(int i16, FILE *file)
{
unsigned char buf[2];
buf[0]=(unsigned char)(i16&0xFF);
return fwrite(buf,2,1,file);
}
-static int write_wav_header()
+
+static int
+write_wav_header()
{
int ret;
FILE *file = stdout;
#endif
+
static int64_t
audio_write (int64_t maxout)
{
int64_t wrote = 0;
wrote = to_write;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Writing %u * %u * %u = %u bytes into PA\n",
- to_write, channels, sizeof (float),
- to_write * channels * sizeof (float));
+ "Writing %u * %u * %u = %llu bytes into PA\n",
+ to_write,
+ channels,
+ (unsigned int) sizeof (float),
+ (unsigned long long) (to_write * channels * sizeof (float)));
#ifdef DEBUG_DUMP_DECODED_OGG
if (dump_to_stdout)
{
so that we can adjust the timestamp counting.*/
gran_offset = preskip;
- if (!pcm_buffer)
+ if (! pcm_buffer)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Allocating %u * %u * %u = %u bytes of buffer space\n",
- MAX_FRAME_SIZE, channels, sizeof (float),
- MAX_FRAME_SIZE * channels * sizeof (float));
+ "Allocating %u * %u * %u = %llu bytes of buffer space\n",
+ MAX_FRAME_SIZE,
+ channels,
+ (unsigned int) sizeof (float),
+ (unsigned long long) (MAX_FRAME_SIZE * channels * sizeof (float)));
pcm_buffer = pa_xmalloc (sizeof (float) * MAX_FRAME_SIZE * channels);
}
}
frame_size = ret;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decoded %d bytes/channel (%d bytes) from %u compressed bytes\n",
- ret, ret * channels, op.bytes);
+ ret,
+ ret * channels,
+ (unsigned int) op.bytes);
/*Apply header gain, if we're not using an opus library new
enough to do this internally.*/
* Callback when data is there for playback
*/
static void
-stream_write_callback (pa_stream * s,
+stream_write_callback (pa_stream *s,
size_t length,
void *userdata)
{
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Unblocking main loop!\n");
- write (ready_pipe[1], "r", 1);
+ (void) write (ready_pipe[1], "r", 1);
}
}
* Exit callback for SIGTERM and SIGINT
*/
static void
-exit_signal_callback (pa_mainloop_api * m, pa_signal_event * e, int sig,
+exit_signal_callback (pa_mainloop_api *m,
+ pa_signal_event *e,
+ int sig,
void *userdata)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
* Pulseaudio stream state callback
*/
static void
-context_state_callback (pa_context * c,
+context_state_callback (pa_context *c,
void *userdata)
{
int p;
break;
case PA_CONTEXT_READY:
{
- GNUNET_assert (!stream_out);
+ GNUNET_assert (! stream_out);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Connection established.\n"));
- if (!(stream_out =
- pa_stream_new (c, "GNUNET VoIP playback", &sample_spec, NULL)))
+ if (! (stream_out =
+ pa_stream_new (c, "GNUNET VoIP playback", &sample_spec, NULL)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("pa_stream_new() failed: %s\n"),