summaryrefslogtreecommitdiffstats
path: root/_build/static/archives/extend/2014-September/000466.html
diff options
context:
space:
mode:
Diffstat (limited to '_build/static/archives/extend/2014-September/000466.html')
-rw-r--r--_build/static/archives/extend/2014-September/000466.html161
1 files changed, 161 insertions, 0 deletions
diff --git a/_build/static/archives/extend/2014-September/000466.html b/_build/static/archives/extend/2014-September/000466.html
new file mode 100644
index 00000000..94dd1886
--- /dev/null
+++ b/_build/static/archives/extend/2014-September/000466.html
@@ -0,0 +1,161 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [99s-extend] Newbie, Cowboy + Websocket + Audio Recording
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Newbie%2C%20Cowboy%20%2B%20Websocket%20%2B%20Audio%20Recording&In-Reply-To=%3CCAKAMJXghRnTZ1CTPkTBapOgh7BnFLUnvL%2B%2BVVedyXuAzWT6HSQ%40mail.gmail.com%3E">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <style type="text/css">
+ pre {
+ white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
+ }
+ </style>
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="000465.html">
+ <LINK REL="Next" HREF="000467.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[99s-extend] Newbie, Cowboy + Websocket + Audio Recording</H1>
+ <B>Eduardo Gurgel</B>
+ <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Newbie%2C%20Cowboy%20%2B%20Websocket%20%2B%20Audio%20Recording&In-Reply-To=%3CCAKAMJXghRnTZ1CTPkTBapOgh7BnFLUnvL%2B%2BVVedyXuAzWT6HSQ%40mail.gmail.com%3E"
+ TITLE="[99s-extend] Newbie, Cowboy + Websocket + Audio Recording">edgurgel at gmail.com
+ </A><BR>
+ <I>Tue Sep 30 00:53:26 CEST 2014</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="000465.html">[99s-extend] Newbie, Cowboy + Websocket + Audio Recording
+</A></li>
+ <LI>Next message: <A HREF="000467.html">[99s-extend] Newbie, Cowboy + Websocket + Audio Recording
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#466">[ date ]</a>
+ <a href="thread.html#466">[ thread ]</a>
+ <a href="subject.html#466">[ subject ]</a>
+ <a href="author.html#466">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>Looking on the output it says:
+
+*{reason,badarith} *on this line:
+
+RecorderPid ! {rec, _Frame/binary},
+
+This may help you somehow.
+
+BTW, variables starting with _ are usually used to show unused variables
+and stop warnings from the compiler.
+
+On 30 September 2014 05:52, Juan Mat&#237;as &lt;<A HREF="https://lists.ninenines.eu/listinfo/extend">jmrepetti at gmail.com</A>&gt; wrote:
+
+&gt;<i> Hello list, I hope this is the right place to ask this.
+</I>&gt;<i>
+</I>&gt;<i> I'm learning Erlang, and I wanted to create a Cowboy app to record audio
+</I>&gt;<i> from a web browser.
+</I>&gt;<i>
+</I>&gt;<i> Based on the websocket example in the Cowboy source code, I get the user
+</I>&gt;<i> mic input and send this input to the websocket.
+</I>&gt;<i>
+</I>&gt;<i> I created a &quot;recorder&quot; module, which functionality is to save the data to
+</I>&gt;<i> the a file.
+</I>&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i> *#rawe_handler.erl*-module(rawec_handler).
+</I>&gt;<i> -behaviour(cowboy_websocket_handler).
+</I>&gt;<i> ......
+</I>&gt;<i> init(_, _, _) -&gt;
+</I>&gt;<i> case whereis(recorder) of
+</I>&gt;<i> undefined -&gt;
+</I>&gt;<i> RecorderPid = recorder:start(),
+</I>&gt;<i> register(recorder, RecorderPid);
+</I>&gt;<i> _ -&gt; ok
+</I>&gt;<i> end,
+</I>&gt;<i> {upgrade, protocol, cowboy_websocket}.
+</I>&gt;<i> .....
+</I>&gt;<i> websocket_handle(_Frame, Req, State) -&gt;
+</I>&gt;<i> RecorderPid = whereis(recorder),
+</I>&gt;<i> RecorderPid ! {rec, _Frame/binary},
+</I>&gt;<i> {ok, Req, State}.
+</I>&gt;<i>
+</I>&gt;<i> *#recorder.erl*
+</I>&gt;<i> -module(recorder).
+</I>&gt;<i>
+</I>&gt;<i> -export([start/0, recorder_fun/1]).
+</I>&gt;<i> -compile([debug_info]).
+</I>&gt;<i>
+</I>&gt;<i> recorder_fun(IoDevice) -&gt;
+</I>&gt;<i> receive
+</I>&gt;<i> {rec, Data} -&gt;
+</I>&gt;<i> ok = file:write(IoDevice, Data),
+</I>&gt;<i> io:format(Data),
+</I>&gt;<i> recorder_fun(IoDevice);
+</I>&gt;<i> {stop, _} -&gt;
+</I>&gt;<i> %%Close file
+</I>&gt;<i> file:close(IoDevice)
+</I>&gt;<i> end.
+</I>&gt;<i>
+</I>&gt;<i> start() -&gt;
+</I>&gt;<i> {ok, IoDevice} = file:open(&quot;/tmp/test_binary.wav&quot;, [write,
+</I>&gt;<i> binary]),
+</I>&gt;<i> spawn(recorder, recorder_fun, [IoDevice]).
+</I>&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i> When I start the console, and allow the microphone on the browser, I see
+</I>&gt;<i> this error on the console:
+</I>&gt;<i>
+</I>&gt;<i> =ERROR REPORT==== 29-Sep-2014::18:13:03 ===
+</I>&gt;<i> Ranch listener http had connection process started with
+</I>&gt;<i> cowboy_protocol:start_link/4 at &lt;0.178.0&gt; exit with reason:
+</I>&gt;<i> *{[{reason,badarith},{mfa,{rawec_handler,websocket_handle,3*}},{stacktrace,[{rawec_handler,websocket_handle,3,[{file,&quot;src/rawec_handler.erl&quot;},{line,35}]},{cowboy_websocket,handler_call,7,[{file,&quot;src/cowboy_websocket.erl&quot;},{line,588}]},{cowboy_protocol,execute,4,[{file,&quot;src/cowboy_protocol.erl&quot;},{line,435}]}]},{msg,{binary,&lt;&lt;0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0....(ETC,
+</I>&gt;<i> DATA STREAM CONTINUES)
+</I>&gt;<i>
+</I>&gt;<i> Probably my approach to do this is totally wrong. I there any obvious
+</I>&gt;<i> problem here?
+</I>&gt;<i> Can someone point me to a right direction?. Maybe I should write directly
+</I>&gt;<i> to a file in the *websocket_handle *funcion, but how can I keep a file
+</I>&gt;<i> opened during the streaming?
+</I>&gt;<i>
+</I>&gt;<i> The github repo is here: <A HREF="https://github.com/jmrepetti/rawec">https://github.com/jmrepetti/rawec</A> with the
+</I>&gt;<i> whole source code if you want to take a look.
+</I>&gt;<i>
+</I>&gt;<i>
+</I>&gt;<i> Thanks in advance,
+</I>&gt;<i> Matias.
+</I>&gt;<i>
+</I>&gt;<i> _______________________________________________
+</I>&gt;<i> Extend mailing list
+</I>&gt;<i> <A HREF="https://lists.ninenines.eu/listinfo/extend">Extend at lists.ninenines.eu</A>
+</I>&gt;<i> <A HREF="https://lists.ninenines.eu/listinfo/extend">https://lists.ninenines.eu/listinfo/extend</A>
+</I>&gt;<i>
+</I>&gt;<i>
+</I>
+
+--
+Eduardo
+-------------- next part --------------
+An HTML attachment was scrubbed...
+URL: &lt;<A HREF="http://lists.ninenines.eu/archives/extend/attachments/20140930/6d952ce6/attachment-0001.html">http://lists.ninenines.eu/archives/extend/attachments/20140930/6d952ce6/attachment-0001.html</A>&gt;
+</PRE>
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="000465.html">[99s-extend] Newbie, Cowboy + Websocket + Audio Recording
+</A></li>
+ <LI>Next message: <A HREF="000467.html">[99s-extend] Newbie, Cowboy + Websocket + Audio Recording
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#466">[ date ]</a>
+ <a href="thread.html#466">[ thread ]</a>
+ <a href="subject.html#466">[ subject ]</a>
+ <a href="author.html#466">[ author ]</a>
+ </LI>
+ </UL>
+
+<hr>
+<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
+mailing list</a><br>
+</body></html>