aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-helper-audio-playback.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-02 21:19:33 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-02 21:19:33 +0000
commit517263c3f5134e5dba57a25e745cb276937602bc (patch)
treec373fee79171adde26b138631bd8d0c371825b69 /src/conversation/gnunet-helper-audio-playback.c
parent875342e4d0114e626dcf502362787d048d5e12fc (diff)
downloadgnunet-517263c3f5134e5dba57a25e745cb276937602bc.tar.gz
gnunet-517263c3f5134e5dba57a25e745cb276937602bc.zip
-use util's mst, remove broken mst.c
Diffstat (limited to 'src/conversation/gnunet-helper-audio-playback.c')
-rw-r--r--src/conversation/gnunet-helper-audio-playback.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/conversation/gnunet-helper-audio-playback.c b/src/conversation/gnunet-helper-audio-playback.c
index 97664d0f5..5fdc217f2 100644
--- a/src/conversation/gnunet-helper-audio-playback.c
+++ b/src/conversation/gnunet-helper-audio-playback.c
@@ -41,19 +41,15 @@
41#define MAXLINE 4096 41#define MAXLINE 4096
42 42
43/** 43/**
44* GNUnet Message Tokenizer 44 * Pulseaudio specification. May change in the future.
45*/ 45 */
46#include "mst.c"
47
48/**
49* Pulseaudio specification. May change in the future.
50*/
51static pa_sample_spec sample_spec = { 46static pa_sample_spec sample_spec = {
52 .format = PA_SAMPLE_FLOAT32LE, 47 .format = PA_SAMPLE_FLOAT32LE,
53 .rate = 48000, 48 .rate = 48000,
54 .channels = 1 49 .channels = 1
55}; 50};
56 51
52
57/** 53/**
58 * Pulseaudio mainloop api 54 * Pulseaudio mainloop api
59 */ 55 */
@@ -123,40 +119,39 @@ static size_t buffer_index;
123/** 119/**
124 * Message callback 120 * Message callback
125 */ 121 */
126static void 122static int
127stdin_receiver (void *cls, 123stdin_receiver (void *cls,
124 void *client,
128 const struct GNUNET_MessageHeader *msg) 125 const struct GNUNET_MessageHeader *msg)
129{ 126{
130 struct AudioMessage *audio; 127 struct AudioMessage *audio;
131 128
132 switch (ntohs (msg->type)) 129 switch (ntohs (msg->type))
133 { 130 {
134 case GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO: 131 case GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO:
135 audio = (struct AudioMessage *) msg; 132 audio = (struct AudioMessage *) msg;
136 133
137 int len = 134 int len =
138 opus_decode_float (dec, 135 opus_decode_float (dec,
139 (const unsigned char *) &audio[1], 136 (const unsigned char *) &audio[1],
140 ntohs (audio->header.size) - sizeof (struct AudioMessage), 137 ntohs (audio->header.size) - sizeof (struct AudioMessage),
141 pcm_buffer, 138 pcm_buffer,
142 frame_size, 0); 139 frame_size, 0);
143 // FIXME: pcm_length != len??? 140 // FIXME: pcm_length != len???
144 if (pa_stream_write 141 if (pa_stream_write
145 (stream_out, (uint8_t *) pcm_buffer, pcm_length, NULL, 0, 142 (stream_out, (uint8_t *) pcm_buffer, pcm_length, NULL, 0,
146 PA_SEEK_RELATIVE) < 0) 143 PA_SEEK_RELATIVE) < 0)
147 { 144 {
148 145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
149 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 146 _("pa_stream_write() failed: %s\n"),
150 _("pa_stream_write() failed: %s\n"), 147 pa_strerror (pa_context_errno (context)));
151 pa_strerror (pa_context_errno (context))); 148 return GNUNET_OK;
152 return; 149 }
153 } 150 break;
154 151 default:
155 break; 152 break;
156 153 }
157 default: 154 return GNUNET_OK;
158 break;
159 }
160} 155}
161 156
162 157
@@ -402,13 +397,14 @@ int
402main (int argc, char *argv[]) 397main (int argc, char *argv[])
403{ 398{
404 char readbuf[MAXLINE]; 399 char readbuf[MAXLINE];
405 struct MessageStreamTokenizer *stdin_mst; 400 struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst;
406 401
402 fprintf (stderr, "HERE!\n");
407 GNUNET_assert (GNUNET_OK == 403 GNUNET_assert (GNUNET_OK ==
408 GNUNET_log_setup ("gnunet-helper-audio-playback", 404 GNUNET_log_setup ("gnunet-helper-audio-playback",
409 "WARNING", 405 "WARNING",
410 NULL)); 406 NULL));
411 stdin_mst = mst_create (&stdin_receiver, NULL); 407 stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, NULL);
412 opus_init (); 408 opus_init ();
413 pa_init (); 409 pa_init ();
414 while (1) 410 while (1)
@@ -421,8 +417,10 @@ main (int argc, char *argv[])
421 strerror (errno)); 417 strerror (errno));
422 break; 418 break;
423 } 419 }
424 mst_receive (stdin_mst, readbuf, ret); 420 GNUNET_SERVER_mst_receive (stdin_mst, NULL,
421 readbuf, ret,
422 GNUNET_NO, GNUNET_NO);
425 } 423 }
426 mst_destroy (stdin_mst); 424 GNUNET_SERVER_mst_destroy (stdin_mst);
427 return 0; 425 return 0;
428} 426}