Audacity  3.0.3
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
ODFLACFile Class Referencefinal

#include <ODDecodeFlacTask.h>

Inheritance diagram for ODFLACFile:
[legend]
Collaboration diagram for ODFLACFile:
[legend]

Public Member Functions

 ODFLACFile (ODFlacDecoder *decoder)
 
bool get_was_error () const
 

Protected Member Functions

FLAC__StreamDecoderWriteStatus write_callback (const FLAC__Frame *frame, const FLAC__int32 *const buffer[]) override
 
void metadata_callback (const FLAC__StreamMetadata *metadata) override
 
void error_callback (FLAC__StreamDecoderErrorStatus status) override
 

Private Attributes

ODFlacDecodermDecoder
 
bool mWasError
 
wxArrayString mComments
 

Friends

class ODFlacDecoder
 

Detailed Description

Definition at line 65 of file ODDecodeFlacTask.h.

Constructor & Destructor Documentation

◆ ODFLACFile()

ODFLACFile::ODFLACFile ( ODFlacDecoder decoder)
inline

Definition at line 68 of file ODDecodeFlacTask.h.

68  : mDecoder(decoder)
69  {
70  mWasError = false;
71  set_metadata_ignore_all();
72  set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT);
73  set_metadata_respond(FLAC__METADATA_TYPE_STREAMINFO);
74  }

References mWasError.

Member Function Documentation

◆ error_callback()

void ODFLACFile::error_callback ( FLAC__StreamDecoderErrorStatus  status)
overrideprotected

Definition at line 90 of file ODDecodeFlacTask.cpp.

91 {
92  mWasError = true;
93 
94 
95  switch (status)
96  {
97  case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
98  wxPrintf("Flac Error: Lost sync\n");
99  break;
100  case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
101  wxPrintf("Flac Error: Crc mismatch\n");
102  break;
103  case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
104  wxPrintf("Flac Error: Bad Header\n");
105  break;
106  default:
107  wxPrintf("Flac Error: Unknown error code\n");
108  break;
109  }
110 }

References mWasError.

◆ get_was_error()

bool ODFLACFile::get_was_error ( ) const
inline

Definition at line 76 of file ODDecodeFlacTask.h.

77  {
78  return mWasError;
79  }

References mWasError.

◆ metadata_callback()

void ODFLACFile::metadata_callback ( const FLAC__StreamMetadata *  metadata)
overrideprotected

Definition at line 46 of file ODDecodeFlacTask.cpp.

47 {
48  switch (metadata->type)
49  {
50  case FLAC__METADATA_TYPE_VORBIS_COMMENT:
51  for (FLAC__uint32 i = 0; i < metadata->data.vorbis_comment.num_comments; i++) {
52  mComments.push_back(UTF8CTOWX((char *)metadata->data.vorbis_comment.comments[i].entry));
53  }
54  break;
55 
56  case FLAC__METADATA_TYPE_STREAMINFO:
57  mDecoder->mSampleRate=metadata->data.stream_info.sample_rate;
58  mDecoder->mNumChannels=metadata->data.stream_info.channels;
59  mDecoder->mBitsPerSample=metadata->data.stream_info.bits_per_sample;
60  mDecoder->mNumSamples=metadata->data.stream_info.total_samples;
61 
62  if (mDecoder->mBitsPerSample<=16) {
65  }
66  } else if (mDecoder->mBitsPerSample<=24) {
69  }
70  } else {
72  }
74  break;
75  // handle the other types we do nothing with to avoid a warning
76  case FLAC__METADATA_TYPE_PADDING: // do nothing with padding
77  case FLAC__METADATA_TYPE_APPLICATION: // no idea what to do with this
78  case FLAC__METADATA_TYPE_SEEKTABLE: // don't need a seektable here
79  case FLAC__METADATA_TYPE_CUESHEET: // convert this to labels?
80  case FLAC__METADATA_TYPE_PICTURE: // ignore pictures
81  case FLAC__METADATA_TYPE_UNDEFINED: // do nothing with this either
82 
83  // FIXME: not declared when compiling on Ubuntu.
84  //case FLAC__MAX_METADATA_TYPE: // quiet compiler warning with this line
85  default:
86  break;
87  }
88 }

References floatSample, int16Sample, int24Sample, ODFlacDecoder::mBitsPerSample, mComments, mDecoder, ODFlacDecoder::mFormat, ODFlacDecoder::mNumChannels, ODFlacDecoder::mNumSamples, ODFlacDecoder::mSampleRate, ODFlacDecoder::mStreamInfoDone, and UTF8CTOWX.

◆ write_callback()

FLAC__StreamDecoderWriteStatus ODFLACFile::write_callback ( const FLAC__Frame *  frame,
const FLAC__int32 *const  buffer[] 
)
overrideprotected

Definition at line 114 of file ODDecodeFlacTask.cpp.

116 {
117 
118  unsigned int bytesToCopy = frame->header.blocksize;
121 
122  //the decodeBuffer was allocated to be the same format as the flac buffer, so we can do a straight up memcpy.
124 
125  mDecoder->mDecodeBufferWritePosition+=bytesToCopy;
126 /*
127  ArrayOf<short> tmp{ frame->header.blocksize };
128 
129  for (unsigned int chn=0; chn<mDecoder->mNumChannels; chn++) {
130  if (frame->header.bits_per_sample == 16) {
131  for (unsigned int s=0; s<frame->header.blocksize; s++) {
132  tmp[s]=buffer[chn][s];
133  }
134 
135  mDecoder->mChannels[chn]->Append((samplePtr)tmp.get(),
136  int16Sample,
137  frame->header.blocksize);
138  }
139  else {
140  mDecoder->mChannels[chn]->Append((samplePtr)buffer[chn],
141  int24Sample,
142  frame->header.blocksize);
143  }
144  }
145 */
146 
147  mDecoder->mSamplesDone += frame->header.blocksize;
148 
149  return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
150 // return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
151 
152 // mDecoder->mUpdateResult = mDecoder->mProgress->Update((wxULongLong_t) mDecoder->mSamplesDone, mDecoder->mNumSamples != 0 ? (wxULongLong_t)mDecoder->mNumSamples : 1);
153 /*
154  if (mDecoder->mUpdateResult != ProgressResult::Success)
155  {
156  return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
157  }
158 
159  return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
160  */
161 }

References ODFlacDecoder::mDecodeBuffer, ODFlacDecoder::mDecodeBufferLen, ODFlacDecoder::mDecodeBufferWritePosition, mDecoder, ODFlacDecoder::mFormat, ODFlacDecoder::mSamplesDone, ODFlacDecoder::mTargetChannel, and SAMPLE_SIZE.

Friends And Related Function Documentation

◆ ODFlacDecoder

friend class ODFlacDecoder
friend

Definition at line 81 of file ODDecodeFlacTask.h.

Member Data Documentation

◆ mComments

wxArrayString ODFLACFile::mComments
private

Definition at line 84 of file ODDecodeFlacTask.h.

Referenced by metadata_callback().

◆ mDecoder

ODFlacDecoder* ODFLACFile::mDecoder
private

Definition at line 82 of file ODDecodeFlacTask.h.

Referenced by metadata_callback(), and write_callback().

◆ mWasError

bool ODFLACFile::mWasError
private

Definition at line 83 of file ODDecodeFlacTask.h.

Referenced by error_callback(), get_was_error(), and ODFLACFile().


The documentation for this class was generated from the following files:
ODFlacDecoder::mDecodeBufferWritePosition
unsigned int mDecodeBufferWritePosition
Definition: ODDecodeFlacTask.h:137
SAMPLE_SIZE
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:44
ODFLACFile::mWasError
bool mWasError
Definition: ODDecodeFlacTask.h:83
int24Sample
@ int24Sample
Definition: SampleFormat.h:33
ODFlacDecoder::mFormat
sampleFormat mFormat
Definition: ODDecodeFlacTask.h:123
ODFlacDecoder::mNumChannels
unsigned long mNumChannels
Definition: ODDecodeFlacTask.h:128
ODFlacDecoder::mSampleRate
unsigned long mSampleRate
Definition: ODDecodeFlacTask.h:127
floatSample
@ floatSample
Definition: SampleFormat.h:34
ODFlacDecoder::mTargetChannel
unsigned int mTargetChannel
Definition: ODDecodeFlacTask.h:136
int16Sample
@ int16Sample
Definition: SampleFormat.h:32
UTF8CTOWX
#define UTF8CTOWX(X)
Definition: Internat.h:159
ODFlacDecoder::mStreamInfoDone
bool mStreamInfoDone
Definition: ODDecodeFlacTask.h:133
ODFlacDecoder::mBitsPerSample
unsigned long mBitsPerSample
Definition: ODDecodeFlacTask.h:129
ODFlacDecoder::mDecodeBufferLen
unsigned int mDecodeBufferLen
Definition: ODDecodeFlacTask.h:138
ODFlacDecoder::mSamplesDone
FLAC__uint64 mSamplesDone
Definition: ODDecodeFlacTask.h:131
ODFlacDecoder::mDecodeBuffer
samplePtr mDecodeBuffer
Definition: ODDecodeFlacTask.h:139
ODFLACFile::mComments
wxArrayString mComments
Definition: ODDecodeFlacTask.h:84
ODFlacDecoder::mNumSamples
FLAC__uint64 mNumSamples
Definition: ODDecodeFlacTask.h:130
ODFLACFile::mDecoder
ODFlacDecoder * mDecoder
Definition: ODDecodeFlacTask.h:82