diff options
Diffstat (limited to 'src/conversation/gnunet-helper-audio-playback.c')
-rw-r--r-- | src/conversation/gnunet-helper-audio-playback.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/src/conversation/gnunet-helper-audio-playback.c b/src/conversation/gnunet-helper-audio-playback.c index 18f63ad18..093b08ec3 100644 --- a/src/conversation/gnunet-helper-audio-playback.c +++ b/src/conversation/gnunet-helper-audio-playback.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @file conversation/gnunet-helper-audio-playback.c | 19 | * @file conversation/gnunet-helper-audio-playback.c |
@@ -149,17 +147,22 @@ process_header (ogg_packet *op) | |||
149 | OpusDecoder *dec; | 147 | OpusDecoder *dec; |
150 | struct OpusHeadPacket header; | 148 | struct OpusHeadPacket header; |
151 | 149 | ||
152 | if (op->bytes < sizeof (header)) | 150 | if ( ((unsigned int) op->bytes) < sizeof (header)) |
153 | return NULL; | 151 | return NULL; |
154 | GNUNET_memcpy (&header, op->packet, sizeof (header)); | 152 | GNUNET_memcpy (&header, |
153 | op->packet, | ||
154 | sizeof (header)); | ||
155 | header.preskip = GNUNET_le16toh (header.preskip); | 155 | header.preskip = GNUNET_le16toh (header.preskip); |
156 | header.sampling_rate = GNUNET_le32toh (header.sampling_rate); | 156 | header.sampling_rate = GNUNET_le32toh (header.sampling_rate); |
157 | header.gain = GNUNET_le16toh (header.gain); | 157 | header.gain = GNUNET_le16toh (header.gain); |
158 | 158 | ||
159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
160 | "Header: v%u, %u-ch, skip %u, %uHz, %u gain\n", | 160 | "Header: v%u, %u-ch, skip %u, %uHz, %u gain\n", |
161 | header.version, header.channels, header.preskip, header.sampling_rate, header.gain); | 161 | header.version, |
162 | 162 | header.channels, | |
163 | header.preskip, | ||
164 | header.sampling_rate, | ||
165 | header.gain); | ||
163 | channels = header.channels; | 166 | channels = header.channels; |
164 | preskip = header.preskip; | 167 | preskip = header.preskip; |
165 | 168 | ||
@@ -338,7 +341,8 @@ audio_write (int64_t maxout) | |||
338 | static void | 341 | static void |
339 | quit (int ret) | 342 | quit (int ret) |
340 | { | 343 | { |
341 | mainloop_api->quit (mainloop_api, ret); | 344 | mainloop_api->quit (mainloop_api, |
345 | ret); | ||
342 | exit (ret); | 346 | exit (ret); |
343 | } | 347 | } |
344 | 348 | ||
@@ -544,6 +548,7 @@ ogg_demux_and_decode () | |||
544 | } | 548 | } |
545 | } | 549 | } |
546 | 550 | ||
551 | |||
547 | /** | 552 | /** |
548 | * Message callback | 553 | * Message callback |
549 | * | 554 | * |
@@ -560,6 +565,7 @@ stdin_receiver (void *cls, | |||
560 | char *data; | 565 | char *data; |
561 | size_t payload_len; | 566 | size_t payload_len; |
562 | 567 | ||
568 | (void) cls; | ||
563 | switch (ntohs (msg->type)) | 569 | switch (ntohs (msg->type)) |
564 | { | 570 | { |
565 | case GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO: | 571 | case GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO: |
@@ -590,6 +596,9 @@ stream_write_callback (pa_stream *s, | |||
590 | void *userdata) | 596 | void *userdata) |
591 | { | 597 | { |
592 | /* unblock 'main' */ | 598 | /* unblock 'main' */ |
599 | (void) userdata; | ||
600 | (void) length; | ||
601 | (void) s; | ||
593 | if (-1 != ready_pipe[1]) | 602 | if (-1 != ready_pipe[1]) |
594 | { | 603 | { |
595 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 604 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -608,6 +617,10 @@ exit_signal_callback (pa_mainloop_api *m, | |||
608 | int sig, | 617 | int sig, |
609 | void *userdata) | 618 | void *userdata) |
610 | { | 619 | { |
620 | (void) m; | ||
621 | (void) e; | ||
622 | (void) sig; | ||
623 | (void) userdata; | ||
611 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 624 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
612 | _("gnunet-helper-audio-playback - Got signal, exiting\n")); | 625 | _("gnunet-helper-audio-playback - Got signal, exiting\n")); |
613 | quit (1); | 626 | quit (1); |
@@ -623,6 +636,7 @@ context_state_callback (pa_context *c, | |||
623 | { | 636 | { |
624 | int p; | 637 | int p; |
625 | 638 | ||
639 | (void) userdata; | ||
626 | GNUNET_assert (NULL != c); | 640 | GNUNET_assert (NULL != c); |
627 | switch (pa_context_get_state (c)) | 641 | switch (pa_context_get_state (c)) |
628 | { | 642 | { |
@@ -735,7 +749,11 @@ ogg_init () | |||
735 | static void | 749 | static void |
736 | drain_callback (pa_stream*s, int success, void *userdata) | 750 | drain_callback (pa_stream*s, int success, void *userdata) |
737 | { | 751 | { |
738 | pa_threaded_mainloop_signal (m, 0); | 752 | (void) s; |
753 | (void) success; | ||
754 | (void) userdata; | ||
755 | pa_threaded_mainloop_signal (m, | ||
756 | 0); | ||
739 | } | 757 | } |
740 | 758 | ||
741 | 759 | ||
@@ -750,7 +768,6 @@ int | |||
750 | main (int argc, char *argv[]) | 768 | main (int argc, char *argv[]) |
751 | { | 769 | { |
752 | static unsigned long long toff; | 770 | static unsigned long long toff; |
753 | |||
754 | char readbuf[MAXLINE]; | 771 | char readbuf[MAXLINE]; |
755 | struct GNUNET_MessageStreamTokenizer *stdin_mst; | 772 | struct GNUNET_MessageStreamTokenizer *stdin_mst; |
756 | char c; | 773 | char c; |
@@ -759,6 +776,8 @@ main (int argc, char *argv[]) | |||
759 | int read_pure_ogg = getenv ("GNUNET_READ_PURE_OGG") ? 1 : 0; | 776 | int read_pure_ogg = getenv ("GNUNET_READ_PURE_OGG") ? 1 : 0; |
760 | #endif | 777 | #endif |
761 | 778 | ||
779 | (void) argc; | ||
780 | (void) argv; | ||
762 | GNUNET_assert (GNUNET_OK == | 781 | GNUNET_assert (GNUNET_OK == |
763 | GNUNET_log_setup ("gnunet-helper-audio-playback", | 782 | GNUNET_log_setup ("gnunet-helper-audio-playback", |
764 | "WARNING", | 783 | "WARNING", |
@@ -783,7 +802,9 @@ main (int argc, char *argv[]) | |||
783 | #endif | 802 | #endif |
784 | while (1) | 803 | while (1) |
785 | { | 804 | { |
786 | ret = read (0, readbuf, sizeof (readbuf)); | 805 | ret = read (STDIN_FILENO, |
806 | readbuf, | ||
807 | sizeof (readbuf)); | ||
787 | toff += ret; | 808 | toff += ret; |
788 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
789 | "Received %d bytes of audio data (total: %llu)\n", | 810 | "Received %d bytes of audio data (total: %llu)\n", |