void CubeSession::SendError(SessionErrorType errorCode, bool close) { log_debug("sending error (fd = %u): %d", static_cast<unsigned int>(fd), errorCode); int code = static_cast<int>(errorCode); StringBuffer sb; Writer<StringBuffer> writer(sb); writer.StartObject(); writer.String("error"); writer.Int(errorCode); writer.String("message"); if (code > SESSIONERROR_UNKNOWN) // user facing error { writer.String(UserFacingErrorMessage[_UE(errorCode)].c_str()); } else { writer.String(SessionErrorMessage[errorCode].c_str()); } writer.EndObject(); SendPackage(sb.GetString()); // is SessionError if (close || static_cast<int>(errorCode) <= static_cast<int>(SESSIONERROR_UNKNOWN)) { FlushAndClose(); } }
void ZKMORFileWriter::CreateFile(const FSRef &parentDir, CFStringRef filename, AudioFileTypeID filetype, const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout) { RemoveFromWorkerThread(); FlushAndClose(); DisposeBuffers(); delete mFile; mFile = NULL; mFile = new CAAudioFile; mFile->CreateNew(parentDir, filename, filetype, dataFormat, layout ? &layout->Layout() : NULL); const CAStreamBasicDescription &fileFmt = mFile->GetFileDataFormat(); CAStreamBasicDescription iofmt; iofmt.SetCanonical(fileFmt.mChannelsPerFrame, false); // deinterleaved iofmt.mSampleRate = fileFmt.mSampleRate; SetClientDataFormat(iofmt); AddToWorkerThread(); }
void ZKMORFileWriter::FlushCloseAndDispose() { FlushAndClose(); // Don't hold a reference to the file anymore -- I can't do anything with it. delete mFile; mFile = NULL; }