C++ C++;-CGI-音频工作不正常

C++ C++;-CGI-音频工作不正常,c++,html,apache,audio,C++,Html,Apache,Audio,我有一个带有HTML5音频元素的网站,其音频数据应通过cgi脚本提供。 标记相当简单: <audio controls> <source type="audio/mpeg" src="audio.cgi?test.mp3"> <em>Me, your browser does not support HTML5 audio</em> </audio> 任何建议和有用的意见都将不胜感激 提前谢谢 p.S.: 忘记提及该行为适用于


我有一个带有HTML5音频元素的网站,其音频数据应通过cgi脚本提供。
标记相当简单:

<audio controls>
  <source type="audio/mpeg" src="audio.cgi?test.mp3">
  <em>Me, your browser does not support HTML5 audio</em>
</audio>
任何建议和有用的意见都将不胜感激
提前谢谢

p.S.:

忘记提及该行为适用于FF 31和IE 11

void serveAudio()
{
    //tried these, were not the right ones
    //getenv("HTTP_RANGE");
    //getenv("HTTP_CONTENT_RANGE");

    ifstream in(audioFile, ios::binary | ios::ate);
    size_t size = in.tellg();
    char *buffer = new char[size];

    in.seekg(0, ios::beg);
    in.read(buffer, size);

    cout<<"Content-Type: audio/mpeg\n\n";
    cout.write(buffer, size);
}