Sorry, I am newbie. Sample codes are from https://github.com/oneman/libflac/tree/master/examples/cpp. I used FLAC__stream_decoder_process_single function but it still gives exception. Maybe I could not control read callback, you're right. I will check it and write result in this thread. Thanks for help. 2013/7/1 Martijn van Beurden <mvanb1 at gmail.com>> I'll top-post this one because it wasn't sent to the mailinglist but to > me. Please reply to list next time. > > I assume you mean the main.c files in the encode and decode directory > under examples. I can't really determine the root cause of your problem > with this information, but I think you're trying to feed the decoder blocks > that are incomplete. The LOST SYNC error is usually seen with corrupted > blocks, so I think the blocks are incomplete or, less likely, corrupt. > > There are a few ways to counter this. The easy way is to add a little > latency to be sure at least one complete block is in the receiving buffer. > So, only call FLAC__stream_decoder_process_single() if the buffer is filled > with enough data. If you want the lowest latency possible you could force a > small block size or let the encoding PC signal the decoding PC when a block > is finished, so the decoding process can be sure there is a full block in > the buffer. > > Oh, and you might take a look at the reading callback, maybe that one is > overreading the buffer? > > I hope that helps. > > > On 01-07-13 17:51, Burak Or?un ?zkablan wrote: > > Martijn, > > I encode a one second captured audio data in my PC and send it to other > PC as encoded. This is OK. > I want to decode data in other PC and play it but when I am decoding data > with decoder stream function, exception throws. > > > 2013/7/1 Burak Or?un ?zkablan <borcunozkablan at gmail.com> > >> Yes, I mean sample codes in FLAC directory. These samples (encode.c and >> decode.c) are about encode/decode with file (using >> FLAC__stream_encoder_init_file and FLAC__stream_decoder_init_file >> functions). >> Streaming which I used is audio data transfer over UDP or TCP sockets of >> boost library. >> >> I send 1 packet which contains 1 second "raw" audio data and header >> information as unsigned char array. In the other PC, I play it. I must do >> it continuously, so I said 'streaming' for this. >> I can stream without FLAC library but I have to do with any codec library >> because our network bandwidth is low so I dont want overhead problem and >> latency. >> >> For streaming, FLAC suggests streaming functions such as >> FLAC__stream_encoder_init_stream, FLAC__stream_decoder_init_stream. The >> decoder stream function takes 3 callback functions, write, read and error. >> What I understand from LOST SYNC exception is write and read callback >> must runs sync. I can not success it, code runs only reading callbacks and >> throws LOST_SYNC exception. >> >> >> 2013/7/1 Martijn van Beurden <mvanb1 at gmail.com> >> >>> On 01-07-13 16:48, Burak Or?un ?zkablan wrote: >>> > [...] >>> > >>> > I run your sample codes, encode.c and decode.c, about file encode / >>> > decode. Then, I run >>> > streaming encode / decode with two different source codes but when I >>> > use streaming encode / decode over network in real-time, code throws >>> > LOST_SYNC exception and only reading callback runs not writing >>> > callback after exception. >>> >>> I'm not sure I understand what you mean. You are talking about file >>> encode and decode ans streaming encode and decode, do you mean the files >>> in the FLAC source directory example? If so, what is the difference, >>> because I only see file encoding examples? >>> >>> Furthermore, I wonder what you mean by stream. Are you serving a file >>> that is being encoded over HTTP, S(a)MB(a), NFS or something specially >>> designed for streaming, like MMS? So, how are you streaming the FLAC >>> file? >>> >>> > How can I solve sync problem over network? Is it possible over network >>> > or does FLAC stream with file? >>> >>> FLAC is capable of streaming, so it should be possible to fix this I >>> guess. >>> _______________________________________________ >>> flac-dev mailing list >>> flac-dev at xiph.org >>> http://lists.xiph.org/mailman/listinfo/flac-dev >>> >> >> >> >> -- >> >> >> Burak Or?un ?ZKABLAN >> >> Computer Science Engineer >> >> >> Mobile : 0 541 302 18 78 <0%20541%20302%2018%2078> >> >> > > > -- > > > Burak Or?un ?ZKABLAN > > Computer Science Engineer > > > Mobile : 0 541 302 18 78 > > > > _______________________________________________ > flac-dev mailing list > flac-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/flac-dev > >-- Burak Or?un ?ZKABLAN Computer Science Engineer Mobile : 0 541 302 18 78 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20130701/b7a1e332/attachment.htm
Hi again, I can not solve problem. I want to mention my source code, so you may answer easily. This is decoder init stream function. *FLAC__stream_decoder_init_stream(m_decoder, decoderReadCallback, NULL, NULL, NULL, NULL, decoderWriteCallback, NULL, decoderErrorCallback, input_pile_array);* * * Then, callbacks * * /// \brief read callback function of decoder FLAC__StreamDecoderReadStatus decoderReadCallback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *callback_param ); /// \brief write callback function of decoder FLAC__StreamDecoderWriteStatus decoderWriteCallback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *callback_param ); /// \brief error callback function of decoder void decoderErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *callback_param ); When I call following statement, *// decode data* *if(!FLAC__stream_decoder_process_single(m_decoder))* * return;* * * firstly, read callback is called. In read callback function, I just use memory copy process. *// copy buffer array to m_pile_array* *if(input_pile_size > 0) {* * memcpy(input_pile_array, buffer, input_pile_size);* * input_pile_size = 0;* * * * * * return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;* *}* * * *return FLAC__STREAM_DECODER_READ_STATUS_ABORT;* * * and I wait for calling write callback but program throws LOST_SYNC exception. I don't know what causes. 2013/7/1 Burak Or?un ?zkablan <borcunozkablan at gmail.com>> Sorry, I am newbie. > > Sample codes are from > https://github.com/oneman/libflac/tree/master/examples/cpp. > I used FLAC__stream_decoder_process_single function but it still gives > exception. Maybe I could not control read callback, you're right. > I will check it and write result in this thread. > > Thanks for help. > > > 2013/7/1 Martijn van Beurden <mvanb1 at gmail.com> > >> I'll top-post this one because it wasn't sent to the mailinglist but to >> me. Please reply to list next time. >> >> I assume you mean the main.c files in the encode and decode directory >> under examples. I can't really determine the root cause of your problem >> with this information, but I think you're trying to feed the decoder blocks >> that are incomplete. The LOST SYNC error is usually seen with corrupted >> blocks, so I think the blocks are incomplete or, less likely, corrupt. >> >> There are a few ways to counter this. The easy way is to add a little >> latency to be sure at least one complete block is in the receiving buffer. >> So, only call FLAC__stream_decoder_process_single() if the buffer is filled >> with enough data. If you want the lowest latency possible you could force a >> small block size or let the encoding PC signal the decoding PC when a block >> is finished, so the decoding process can be sure there is a full block in >> the buffer. >> >> Oh, and you might take a look at the reading callback, maybe that one is >> overreading the buffer? >> >> I hope that helps. >> >> >> On 01-07-13 17:51, Burak Or?un ?zkablan wrote: >> >> Martijn, >> >> I encode a one second captured audio data in my PC and send it to other >> PC as encoded. This is OK. >> I want to decode data in other PC and play it but when I am decoding data >> with decoder stream function, exception throws. >> >> >> 2013/7/1 Burak Or?un ?zkablan <borcunozkablan at gmail.com> >> >>> Yes, I mean sample codes in FLAC directory. These samples (encode.c and >>> decode.c) are about encode/decode with file (using >>> FLAC__stream_encoder_init_file and FLAC__stream_decoder_init_file >>> functions). >>> Streaming which I used is audio data transfer over UDP or TCP sockets of >>> boost library. >>> >>> I send 1 packet which contains 1 second "raw" audio data and header >>> information as unsigned char array. In the other PC, I play it. I must do >>> it continuously, so I said 'streaming' for this. >>> I can stream without FLAC library but I have to do with any codec >>> library because our network bandwidth is low so I dont want overhead >>> problem and latency. >>> >>> For streaming, FLAC suggests streaming functions such as >>> FLAC__stream_encoder_init_stream, FLAC__stream_decoder_init_stream. The >>> decoder stream function takes 3 callback functions, write, read and error. >>> What I understand from LOST SYNC exception is write and read callback >>> must runs sync. I can not success it, code runs only reading callbacks and >>> throws LOST_SYNC exception. >>> >>> >>> 2013/7/1 Martijn van Beurden <mvanb1 at gmail.com> >>> >>>> On 01-07-13 16:48, Burak Or?un ?zkablan wrote: >>>> > [...] >>>> > >>>> > I run your sample codes, encode.c and decode.c, about file encode / >>>> > decode. Then, I run >>>> > streaming encode / decode with two different source codes but when I >>>> > use streaming encode / decode over network in real-time, code throws >>>> > LOST_SYNC exception and only reading callback runs not writing >>>> > callback after exception. >>>> >>>> I'm not sure I understand what you mean. You are talking about file >>>> encode and decode ans streaming encode and decode, do you mean the files >>>> in the FLAC source directory example? If so, what is the difference, >>>> because I only see file encoding examples? >>>> >>>> Furthermore, I wonder what you mean by stream. Are you serving a file >>>> that is being encoded over HTTP, S(a)MB(a), NFS or something specially >>>> designed for streaming, like MMS? So, how are you streaming the FLAC >>>> file? >>>> >>>> > How can I solve sync problem over network? Is it possible over network >>>> > or does FLAC stream with file? >>>> >>>> FLAC is capable of streaming, so it should be possible to fix this I >>>> guess. >>>> _______________________________________________ >>>> flac-dev mailing list >>>> flac-dev at xiph.org >>>> http://lists.xiph.org/mailman/listinfo/flac-dev >>>> >>> >>> >>> >>> -- >>> >>> >>> Burak Or?un ?ZKABLAN >>> >>> Computer Science Engineer >>> >>> >>> Mobile : 0 541 302 18 78 <0%20541%20302%2018%2078> >>> >>> >> >> >> -- >> >> >> Burak Or?un ?ZKABLAN >> >> Computer Science Engineer >> >> >> Mobile : 0 541 302 18 78 >> >> >> >> _______________________________________________ >> flac-dev mailing list >> flac-dev at xiph.org >> http://lists.xiph.org/mailman/listinfo/flac-dev >> >> > > > -- > > > Burak Or?un ?ZKABLAN > > Computer Science Engineer > > > Mobile : 0 541 302 18 78 > >-- Burak Or?un ?ZKABLAN Computer Science Engineer Mobile : 0 541 302 18 78 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20130702/c3875637/attachment.htm
Martijn, I don't use any metadata when encoding and decoding. When I call *FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(m_decoder)] * * * it returns FLAC__STREAM_DECODER_SEARCH_FOR_METADATA enum value. Is it an error ? 2013/7/2 Burak Or?un ?zkablan <borcunozkablan at gmail.com>> Hi again, > > I can not solve problem. I want to mention my source code, so you may > answer easily. > > This is decoder init stream function. > > *FLAC__stream_decoder_init_stream(m_decoder, decoderReadCallback, NULL, > NULL, NULL, NULL, decoderWriteCallback, NULL, decoderErrorCallback, > input_pile_array);* > * > * > Then, callbacks > * > * > /// \brief read callback function of decoder > FLAC__StreamDecoderReadStatus decoderReadCallback(const > FLAC__StreamDecoder *decoder, > FLAC__byte buffer[], > size_t *bytes, > void *callback_param > ); > > /// \brief write callback function of decoder > FLAC__StreamDecoderWriteStatus decoderWriteCallback(const > FLAC__StreamDecoder *decoder, > const FLAC__Frame *frame, > const FLAC__int32 * const buffer[], > void *callback_param > ); > > /// \brief error callback function of decoder > void decoderErrorCallback(const FLAC__StreamDecoder *decoder, > FLAC__StreamDecoderErrorStatus status, > void *callback_param > ); > > When I call following statement, > > *// decode data* > *if(!FLAC__stream_decoder_process_single(m_decoder))* > * return;* > * > * > firstly, read callback is called. In read callback function, I just use > memory copy process. > > *// copy buffer array to m_pile_array* > *if(input_pile_size > 0) {* > * memcpy(input_pile_array, buffer, input_pile_size);* > * input_pile_size = 0;* > * > * > * > * > * return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;* > *}* > * > * > *return FLAC__STREAM_DECODER_READ_STATUS_ABORT;* > * > * > and I wait for calling write callback but program throws LOST_SYNC > exception. I don't know what causes. > > > 2013/7/1 Burak Or?un ?zkablan <borcunozkablan at gmail.com> > >> Sorry, I am newbie. >> >> Sample codes are from >> https://github.com/oneman/libflac/tree/master/examples/cpp. >> I used FLAC__stream_decoder_process_single function but it still gives >> exception. Maybe I could not control read callback, you're right. >> I will check it and write result in this thread. >> >> Thanks for help. >> >> >> 2013/7/1 Martijn van Beurden <mvanb1 at gmail.com> >> >>> I'll top-post this one because it wasn't sent to the mailinglist but >>> to me. Please reply to list next time. >>> >>> I assume you mean the main.c files in the encode and decode directory >>> under examples. I can't really determine the root cause of your problem >>> with this information, but I think you're trying to feed the decoder blocks >>> that are incomplete. The LOST SYNC error is usually seen with corrupted >>> blocks, so I think the blocks are incomplete or, less likely, corrupt. >>> >>> There are a few ways to counter this. The easy way is to add a little >>> latency to be sure at least one complete block is in the receiving buffer. >>> So, only call FLAC__stream_decoder_process_single() if the buffer is filled >>> with enough data. If you want the lowest latency possible you could force a >>> small block size or let the encoding PC signal the decoding PC when a block >>> is finished, so the decoding process can be sure there is a full block in >>> the buffer. >>> >>> Oh, and you might take a look at the reading callback, maybe that one is >>> overreading the buffer? >>> >>> I hope that helps. >>> >>> >>> On 01-07-13 17:51, Burak Or?un ?zkablan wrote: >>> >>> Martijn, >>> >>> I encode a one second captured audio data in my PC and send it to >>> other PC as encoded. This is OK. >>> I want to decode data in other PC and play it but when I am decoding >>> data with decoder stream function, exception throws. >>> >>> >>> 2013/7/1 Burak Or?un ?zkablan <borcunozkablan at gmail.com> >>> >>>> Yes, I mean sample codes in FLAC directory. These samples (encode.c and >>>> decode.c) are about encode/decode with file (using >>>> FLAC__stream_encoder_init_file and FLAC__stream_decoder_init_file >>>> functions). >>>> Streaming which I used is audio data transfer over UDP or TCP sockets >>>> of boost library. >>>> >>>> I send 1 packet which contains 1 second "raw" audio data and header >>>> information as unsigned char array. In the other PC, I play it. I must do >>>> it continuously, so I said 'streaming' for this. >>>> I can stream without FLAC library but I have to do with any codec >>>> library because our network bandwidth is low so I dont want overhead >>>> problem and latency. >>>> >>>> For streaming, FLAC suggests streaming functions such as >>>> FLAC__stream_encoder_init_stream, FLAC__stream_decoder_init_stream. The >>>> decoder stream function takes 3 callback functions, write, read and error. >>>> What I understand from LOST SYNC exception is write and read callback >>>> must runs sync. I can not success it, code runs only reading callbacks and >>>> throws LOST_SYNC exception. >>>> >>>> >>>> 2013/7/1 Martijn van Beurden <mvanb1 at gmail.com> >>>> >>>>> On 01-07-13 16:48, Burak Or?un ?zkablan wrote: >>>>> > [...] >>>>> > >>>>> > I run your sample codes, encode.c and decode.c, about file encode / >>>>> > decode. Then, I run >>>>> > streaming encode / decode with two different source codes but when I >>>>> > use streaming encode / decode over network in real-time, code throws >>>>> > LOST_SYNC exception and only reading callback runs not writing >>>>> > callback after exception. >>>>> >>>>> I'm not sure I understand what you mean. You are talking about file >>>>> encode and decode ans streaming encode and decode, do you mean the >>>>> files >>>>> in the FLAC source directory example? If so, what is the difference, >>>>> because I only see file encoding examples? >>>>> >>>>> Furthermore, I wonder what you mean by stream. Are you serving a file >>>>> that is being encoded over HTTP, S(a)MB(a), NFS or something specially >>>>> designed for streaming, like MMS? So, how are you streaming the FLAC >>>>> file? >>>>> >>>>> > How can I solve sync problem over network? Is it possible over >>>>> network >>>>> > or does FLAC stream with file? >>>>> >>>>> FLAC is capable of streaming, so it should be possible to fix this I >>>>> guess. >>>>> _______________________________________________ >>>>> flac-dev mailing list >>>>> flac-dev at xiph.org >>>>> http://lists.xiph.org/mailman/listinfo/flac-dev >>>>> >>>> >>>> >>>> >>>> -- >>>> >>>> >>>> Burak Or?un ?ZKABLAN >>>> >>>> Computer Science Engineer >>>> >>>> >>>> Mobile : 0 541 302 18 78 <0%20541%20302%2018%2078> >>>> >>>> >>> >>> >>> -- >>> >>> >>> Burak Or?un ?ZKABLAN >>> >>> Computer Science Engineer >>> >>> >>> Mobile : 0 541 302 18 78 >>> >>> >>> >>> _______________________________________________ >>> flac-dev mailing list >>> flac-dev at xiph.org >>> http://lists.xiph.org/mailman/listinfo/flac-dev >>> >>> >> >> >> -- >> >> >> Burak Or?un ?ZKABLAN >> >> Computer Science Engineer >> >> >> Mobile : 0 541 302 18 78 >> >> > > > -- > > > Burak Or?un ?ZKABLAN > > Computer Science Engineer > > > Mobile : 0 541 302 18 78 > >-- Burak Or?un ?ZKABLAN Computer Science Engineer Mobile : 0 541 302 18 78 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20130702/2728881e/attachment-0001.htm