diff options
author | Loïc Hoguin <[email protected]> | 2016-08-29 12:39:49 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-08-29 12:40:03 +0200 |
commit | c807880f7ac73f813b2660ea81a00f7712a4e793 (patch) | |
tree | ba1d09e9b177f230665a80513b33fbd532000ce4 /_build/static/archives/extend/attachments/20140929 | |
parent | b1df25a7d9cda697513650659b781b55b40898f8 (diff) | |
download | ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.gz ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.bz2 ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.zip |
Add old mailing list archives
Diffstat (limited to '_build/static/archives/extend/attachments/20140929')
-rw-r--r-- | _build/static/archives/extend/attachments/20140929/84fe21a4/attachment-0001.html | 5 | ||||
-rw-r--r-- | _build/static/archives/extend/attachments/20140929/84fe21a4/attachment.html | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/_build/static/archives/extend/attachments/20140929/84fe21a4/attachment-0001.html b/_build/static/archives/extend/attachments/20140929/84fe21a4/attachment-0001.html new file mode 100644 index 00000000..d8a3a0b0 --- /dev/null +++ b/_build/static/archives/extend/attachments/20140929/84fe21a4/attachment-0001.html @@ -0,0 +1,5 @@ +<tt> +<div dir="ltr"><div>Hello list, I hope this is the right place to ask this.<br><br></div><div>I'm learning Erlang, and I wanted to create a Cowboy app to record audio from a web browser.<br><br>Based on the websocket example in the Cowboy source code, I get the user mic input and send this input to the websocket.<br><br></div><div>I created a "recorder" module, which functionality is to save the data to the a file.<br><br><b>#rawe_handler.erl<br></b>-module(rawec_handler).<br>-behaviour(cowboy_websocket_handler).<br>......<br>init(_, _, _) -><br> case whereis(recorder) of<br> undefined -><br> RecorderPid = recorder:start(),<br> register(recorder, RecorderPid);<br> _ -> ok<br> end,<br> {upgrade, protocol, cowboy_websocket}.<br>.....<br>websocket_handle(_Frame, Req, State) -><br> RecorderPid = whereis(recorder),<br> RecorderPid ! {rec, _Frame/binary},<br> {ok, Req, State}.<br><br></div><div><b>#recorder.erl</b><br>-module(recorder).<br><br>-export([start/0, recorder_fun/1]).<br>-compile([debug_info]).<br><br>recorder_fun(IoDevice) -> <br> receive<br> {rec, Data} -><br> ok = file:write(IoDevice, Data),<br> io:format(Data),<br> recorder_fun(IoDevice);<br> {stop, _} -><br> %%Close file<br> file:close(IoDevice)<br> end.<br> <br>start() -><br> {ok, IoDevice} = file:open("/tmp/test_binary.wav", [write, binary]), <br> spawn(recorder, recorder_fun, [IoDevice]).<br> <br><br></div><div>When I start the console, and allow the microphone on the browser, I see this error on the console:<br><br>=ERROR REPORT==== 29-Sep-2014::18:13:03 ===<br>Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.178.0> exit with reason: <b>{[{reason,badarith},{mfa,{rawec_handler,websocket_handle,3</b>}},{stacktrace,[{rawec_handler,websocket_handle,3,[{file,"src/rawec_handler.erl"},{line,35}]},{cowboy_websocket,handler_call,7,[{file,"src/cowboy_websocket.erl"},{line,588}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,435}]}]},{msg,{binary,<<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, DATA STREAM CONTINUES)<br></div><div><br></div><div>Probably my approach to do this is totally wrong. I there any obvious problem here?<br></div><div>Can someone point me to a right direction?. Maybe I should write directly to a file in the <b>websocket_handle </b>funcion, but how can I keep a file opened during the streaming?<br><br></div><div>The github repo is here: <a href="https://github.com/jmrepetti/rawec">https://github.com/jmrepetti/rawec</a> with the whole source code if you want to take a look.<br><br><br></div><div>Thanks in advance,<br></div><div>Matias.<br><br> +</div></div><br> + +</tt> diff --git a/_build/static/archives/extend/attachments/20140929/84fe21a4/attachment.html b/_build/static/archives/extend/attachments/20140929/84fe21a4/attachment.html new file mode 100644 index 00000000..d8a3a0b0 --- /dev/null +++ b/_build/static/archives/extend/attachments/20140929/84fe21a4/attachment.html @@ -0,0 +1,5 @@ +<tt> +<div dir="ltr"><div>Hello list, I hope this is the right place to ask this.<br><br></div><div>I'm learning Erlang, and I wanted to create a Cowboy app to record audio from a web browser.<br><br>Based on the websocket example in the Cowboy source code, I get the user mic input and send this input to the websocket.<br><br></div><div>I created a "recorder" module, which functionality is to save the data to the a file.<br><br><b>#rawe_handler.erl<br></b>-module(rawec_handler).<br>-behaviour(cowboy_websocket_handler).<br>......<br>init(_, _, _) -><br> case whereis(recorder) of<br> undefined -><br> RecorderPid = recorder:start(),<br> register(recorder, RecorderPid);<br> _ -> ok<br> end,<br> {upgrade, protocol, cowboy_websocket}.<br>.....<br>websocket_handle(_Frame, Req, State) -><br> RecorderPid = whereis(recorder),<br> RecorderPid ! {rec, _Frame/binary},<br> {ok, Req, State}.<br><br></div><div><b>#recorder.erl</b><br>-module(recorder).<br><br>-export([start/0, recorder_fun/1]).<br>-compile([debug_info]).<br><br>recorder_fun(IoDevice) -> <br> receive<br> {rec, Data} -><br> ok = file:write(IoDevice, Data),<br> io:format(Data),<br> recorder_fun(IoDevice);<br> {stop, _} -><br> %%Close file<br> file:close(IoDevice)<br> end.<br> <br>start() -><br> {ok, IoDevice} = file:open("/tmp/test_binary.wav", [write, binary]), <br> spawn(recorder, recorder_fun, [IoDevice]).<br> <br><br></div><div>When I start the console, and allow the microphone on the browser, I see this error on the console:<br><br>=ERROR REPORT==== 29-Sep-2014::18:13:03 ===<br>Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.178.0> exit with reason: <b>{[{reason,badarith},{mfa,{rawec_handler,websocket_handle,3</b>}},{stacktrace,[{rawec_handler,websocket_handle,3,[{file,"src/rawec_handler.erl"},{line,35}]},{cowboy_websocket,handler_call,7,[{file,"src/cowboy_websocket.erl"},{line,588}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,435}]}]},{msg,{binary,<<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, DATA STREAM CONTINUES)<br></div><div><br></div><div>Probably my approach to do this is totally wrong. I there any obvious problem here?<br></div><div>Can someone point me to a right direction?. Maybe I should write directly to a file in the <b>websocket_handle </b>funcion, but how can I keep a file opened during the streaming?<br><br></div><div>The github repo is here: <a href="https://github.com/jmrepetti/rawec">https://github.com/jmrepetti/rawec</a> with the whole source code if you want to take a look.<br><br><br></div><div>Thanks in advance,<br></div><div>Matias.<br><br> +</div></div><br> + +</tt> |